加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

angularjs应用

发布时间:2020-12-17 09:36:39 所属栏目:安全 来源:网络整理
导读:AngularJS 应用 AngularJS 模块(Module) 定义了 AngularJS 应用。 AngularJS 控制器(Controller) 用于控制 AngularJS 应用。 ng-app 指令定义了应用, ng-controller 定义了控制器。 ------html----- html ng-app="test" ng-controller='ctr' head meta c

AngularJS 应用

AngularJS模块(Module)定义了 AngularJS 应用。

AngularJS控制器(Controller)用于控制 AngularJS 应用。

ng-app指令定义了应用,ng-controller定义了控制器。

------html-----

<html ng-app="test" ng-controller='ctr' >
<head>
<meta charset="utf-8">
<script type="text/javascript" src="js/angular.min.js">
</script>
<script type="text/javascript" src="js/module.js">
</script>
</head>
<body >
<input type="text" ng-model="firstName" />
姓名是{{firstName}}
</div>
</body>


---js---

var app=angular.module('test',[]);
app.controller("ctr",function($scope){ //%scope是ng应用的作用域

$scope.firstName='haha';


});

---问题---当将ng-controller放在<input type="text" ng-controller='ctr'ng-model="firstName" />的时候。只能在input输入框里面显示初始值,而表达式则无法显示。这个指令的位置产生这种现象是因为其执行顺序导致的还是?

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读