4. AngularJS 作用域
使用作用域
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Simple app</title> <script src="http://apps.bdimg.com/libs/angular.js/1.2.16/angular.min.js"></script> </head> <body> <div ng-app="myApp"> <h1>hello {{ name }} </h1> </div> <script type="text/javascript"> angular.module('myApp', []) .run(function ($rootScope) { $rootScope.name = "World"; }); </script> </body> </html>