angularjs - Angular.js how to programatically create new ng-model -
i'm trying add "<label>foos name</label><input ng-model="foo"/>"
programmatically dom part of string, have this.
.directive( 'showdata', function ( $compile ) { return { scope: true, link: function ( scope, element, attrs ) { var el; attrs.$observe( 'template', function ( tpl ) { if ( angular.isdefined( tpl ) ) { // compile provided template against current scope el = $compile(tpl)( scope ); // stupid way of emptying element element.html(""); // add template content element.append( el ); } }); } }; });
problem is, $scope.foo
doesn't exist...
any ideas?
thanks in advance
ok, figured out why wasn't working.. simple too..
i had $scope.foo = '' defined in controller overriding 1 included in string.
Comments
Post a Comment