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.

working fiddle


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -