title: AngularJS dynamic form field with adding required attribute
body: <p>I am trying to validate some form fields which are given to me from a backend. I want to be able to add the required attribute if that field name needs that attribute. Here is what I have html side:</p>
  
  <pre><code>      &lt;div class="form-group"&gt;
  
          &lt;!-- ************** ADDITIONAL DYNAMIC FIELDS ******** --&gt;
  
               &lt;div ng-repeat="field in assetFields" ng-cloak&gt;
                    &lt;div class="col-sm-6"&gt;
                       &lt;input type="@{{field.element_type}}" name="@{{field.property}}" class="form-control input-lg" value="" id="@{{field.property}}"&gt;
                  &lt;/div&gt;
        &lt;/div&gt;
  </code></pre>
  
  <p>Here is Angularjs side of it: </p>
  
  <pre><code>$http.get('/getAssetFeilds/'+$scope.assetType).success(function(data)
              {
                  console.log(data);
                  $scope.assetFields = data;
  
                   //loop through the array of json objects
                  angular.forEach(data, function(input, key){
                      //get the type of element
                      if(input.element_type == 'text'){
                          //loop through input validations 
                          angular.forEach(input.validations, function(value, key){
                              //check if this input type field is required
                              if(value == 'required'){
                                  console.log("#"+input.property);
                                  //find the element id value and add required attribute
                                  angular.element("#"+input.property).attr('required', 'required');
                              }
  
                          });
                      }
                  });
  
              });
  </code></pre>
  
  <p>However,its not adding the attribute when I do inspect element. what could be the reason for this not working? which I thought would have worked.</p>