I have a page in which based on the one drop down value few more input fields are added. This page is driven by angularjs. Only for inducing additional input fields i have used jquery like this.
Html:
<label for="Type">MyDataType:</label>
<select ng-model="myData.Type" id="selectBox" >
<option value="UL">Other</option>
<option value="AUL">Auto</option>
</select>
<div id="outputArea">
$("#selectBox").change(function() {
var htmlString = "";
var len = $(this).val();
if (len == 'AUL'){
htmlString = "<label for=\"Auto#\">Auto#:</label><input type=\"text\"ng-model=\"mydata.autoNum\">";
}
})
But angular is not able to recognize this ng-model When i do a console.log($scope.myData.autoNum); it will tell undefined. Please suggest me on this.
If AUL value is selected i need to include mydata.autoNum input field. And if user selects UL then mydata.autoNum should not display.
$compilewhen injecting the html that has directives in it. But why are you using jQuery for this at all? It is very simply done in angular template and there is no need for the jQuery shown. Provide your template structure for more detailsng-if. Need more code context to be able to help more