AngularJS Modules/Scope Sharing

后端 未结 2 2306
北海茫月
北海茫月 2020-12-15 00:30

I recently started using AngularJS and the way I\'m building my apps now is like this:

MainController.js

var app = angular.module(\'app\', [\'SomeC         


        
2条回答
  •  北荒
    北荒 (楼主)
    2020-12-15 00:53

    You can use $rootScope, each Angular application has exactly one root scope.

    Reference

    app.controller('MainController', function ($scope, $rootScope) {
        $rootScope.data = 'App scope data';
    }
    

提交回复
热议问题