The following is the method I found to define global variables (please point out if there is any misunderstanding):
1,myApp.run(function($rootScope) {
$rootScope.haha = 'test';
});
2.<p ng-app="myApp" ng-init="haha='test';">
3.app.value(key, value)
4.app.constant(key, value)
I found that there are only 1 and 2. I can directly output it in the template: {{haha}}, but I don’t know how to call it in the controller?
Then 3 and 4, I can’t output them in the template, let alone in the controller.
Thank you!
1
3/4
http://hellobug.github.io/blog/angularjs...