Pass an object to angularjs template from jade

梦想与她 提交于 2019-12-04 08:18:45

You can do this into your script:

var data = !{JSON.stringify(userData)};
window.serverData= data;

After in your app.js, you can do this:

app.value('serverData', window.serverData);

And in your controller:

app.controller('controllerName', ['serverData', function(serverData){

console.log(serverData);

}]);

You can access to window var into the controller without doing app.value, but it is a good practice.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!