搜索文档
首页
HTML/CSS
JavaScript
服务端开发
Java教程
移动端
数据库
当前位置:
首页
JavaScript
AngularJS 教程
AngularJS 基础教程
源代码
清空
点击运行
<html> <head> <title>Angular JS Forms</title> </head> <body> <h2>AngularJS Scope(作用域)</h2> <div ng-app = "mainApp" ng-controller = "shapeController"> <p>{{message}} <br/> {{type}} </p> <div ng-controller = "circleController"> <p>{{message}} <br/> {{type}} </p> </div> <div ng-controller = "squareController"> <p>{{message}} <br/> {{type}} </p> </div> </div> <script src = "https://cdn.staticfile.org/angular.js/1.3.14/angular.min.js"> </script> <script> var mainApp = angular.module("mainApp", []); mainApp.controller("shapeController", function($scope) { $scope.message = "形状控制器"; $scope.type = "Shape"; }); mainApp.controller("circleController", function($scope) { $scope.message = "圆圈控制器"; }); mainApp.controller("squareController", function($scope) { $scope.message = "方形控制器"; $scope.type = "Square"; }); </script> </body> </html>
运行结果