1 $rootScope run : run 方法初始化全局的数据 ,只对全局作用域起作用 如$rootScope
<script src="http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js"></script> <div ng-app="a" > {{name}} </div> <script> var app=angular.module(‘a‘,[]); app.run(function ($rootScope) { $rootScope.name=‘sdfa‘; }); </script>
时间: 2024-11-06 17:51:21