AngularJS

作用域-$rootScope

by dream apple

HTML

<div ng-app="MyApp">
    <div ng-controller="MyController">
        <h1>{{sayWhat}}</h1>
    </div>
</div>

JavaScript

angular.module("MyApp",[])
.controller("MyController", function($rootScope){
    $rootScope.sayWhat = "Hello World";
});