angularjs - ng-include on load with an object -
this works
<div ng-include="template.html" onload="person='jane'"></div> ^ sets local scope variable person in include 'jane' (string)
but want pass person object called user: {name: 'jane' }
<div ng-include="template.html" onload="person=user"></div> ^ sets local scope variable person in include 'undefined'
how possible pass object local variable ng-include?
maybe want custom directive:
<div person-directive="{name:'jane'}"></div> js:
angular.module('myapp',[]) .directive('persondirective',function(){     return {         restrict: 'a',         scope: {             person: '=persondirective'         },         templateurl: 'template.html'     }; }); with this, bind passed-in value person in loaded template.
Comments
Post a Comment