首页 > Web开发 > 详细

AngulatJS Controller

时间:2014-04-23 00:05:20      阅读:587      评论:0      收藏:0      [点我收藏+]
bubuko.com,布布扣
<!DOCTYPE html>

<html ng-app="demo">
<head>
    <title></title>
</head>
<body>
    <input type="text" ng-model="data.message" />
    <h1>{{data.message}}</h1>
    <div ng-controller="firstCtl">
        <input type="text" ng-model="data.message" />
        <h1>{{data.message}}</h1>
    </div>
    <div ng-controller="secondCtl">
        <input type="text" ng-model="data.message" />
        <h1>{{data.message}}</h1>
    </div>
</body>
<script src="angular.min.js" type="text/javascript"></script>
<script>
    var demo = angular.module("demo", []);
    demo.controller("firstCtl", function ($scope) {
        $scope.data = {message:"JACKEY"};
    });
    demo.controller("secondCtl", function ($scope) {
        $scope.data = { message: "cSSI" };
    });
</script>

</html>
bubuko.com,布布扣

bubuko.com,布布扣

这个例子给我的认识是:

没有声明在controller里面的全局message会对声明在controller里面的message产生影响,

firstCtl不对secondCtl产生影响

AngulatJS Controller,布布扣,bubuko.com

AngulatJS Controller

原文:http://www.cnblogs.com/lihaozhou/p/3679430.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!