javascript - AngularJS ng-model for multiple inputs inside directive -
so have directive 21 inputs in it. want set ng-modelbased on attribute passed when calling directive. if {{myattr}}
inside directive outputs attribute i've set, if include ng-model="{{myattr}}"
things break.
angular.module('myapp') .directive('program', function () { return { templateurl: 'app/program/program.html', restrict: 'ea', link: function (scope, element, attrs) { scope.daymodel = 'program.' + attrs.day + 'first'; } }; });
you use {{variablename}}
in pure html-text, angularjs can replace value of variable @ runtime:
http://jsfiddle.net/joshdmiller/hb7lu/
but never write ng-form="{{myattr}}"
in html-tag, instead have write ng-form="myattr"
{{}}
serves way angularjs distinguish between plain text , variable/code. in html-tags there no plain text, instead interpreted variable/code.
Comments
Post a Comment