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

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -