Angular1.63 绑定数据与继承
html 部分
<body ng-app="myapp">
<div ng-controller="asd">
<p><span ng-bind="firstName"></span></p>
</div>
<div ng-controller="qwe">
<p><span ng-bind="firstName"></span></p>
</div>
---------------------------------
script部分
<script src="js/angular.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
var? app = angular.module("myapp", []);?
app.controller('asd', function($scope) {??? //$scope數(shù)據(jù) 類似vue中的data
$scope.firstName = "John";??? // 綁定數(shù)據(jù) 必須是$scope.xx=xx
$scope.lastName = "Doe"; })// 綁定數(shù)據(jù)
app.controller('qwe', function($scope) {??? //$scope數(shù)據(jù) 類似vue中的data
$scope.firstName = "zlt";??? // 綁定數(shù)據(jù) 必須是$scope.xx=xx
$scope.lastName = "Doe"; })
---------------------
ng-controller ? 一個頁面上可以有多個,還可以嵌套使用,存在父子關系
例如
<div ng-controller="asd">
<p><span ng-bind="firstName"></span></p>
<div ng-controller="qwe">
<p><span ng-bind="firstName"></span></p> ? john
</div>
</div>
嵌套了一個ng-controller="qwe"
?
---------------
<script type="text/javascript">
var? app = angular.module("myapp", []);?
app.controller('asd', function($scope) {??? //$scope數(shù)據(jù) 類似vue中的data
$scope.firstName = "John";??? // 綁定數(shù)據(jù) 必須是$scope.xx=xx
$scope.lastName = "Doe"; })// 綁定數(shù)據(jù)
app.controller('qwe', function($scope) {??? //$scope數(shù)據(jù) 類似vue中的data
$scope.apple = "123123";??? // 綁定數(shù)據(jù) 必須是$scope.xx=xx
$scope.apples = "543"; })// 綁定數(shù)據(jù)
</script>
子?ng-controller="qwe"的?ng-bind="firstName" 就是 父級的 john
-----------------------------
?
轉載于:https://www.cnblogs.com/nns4/p/6999622.html
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎勵來咯,堅持創(chuàng)作打卡瓜分現(xiàn)金大獎總結
以上是生活随笔為你收集整理的Angular1.63 绑定数据与继承的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 安川服务器电源板过流维修,安川伺服驱动器
- 下一篇: oracle导出数据dummy,orac