課程
/前端開發(fā)
/Angular
/AngularJS實戰(zhàn)
templateUrl外部引入為什么可以獲取父級的scope?
2016-12-16
源自:AngularJS實戰(zhàn) 2-11
正在回答
因為templateUrl模板所在的作用域在父級作用域$scope下,比如:
????????.state('home.list',?{ ????????????url:?'/list', ????????????templateUrl:?'tpls/home-list.html',???? ????????????controller:?function($scope)?{ ????????????????$scope.topics?=?['Butterscotch',?'Black?Current',?'Mango']; ????????????} ????????})
home-list.html內(nèi)容如下:
<ul> ????<li?ng-repeat="topic?in?topics">{{?topic?}}</li> </ul>
效果如下:
舉報
一起學習AngularJS的基礎教程,通過實例學習并學會AngularJS
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網(wǎng)安備11010802030151號
購課補貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動學習伙伴
掃描二維碼關注慕課網(wǎng)微信公眾號
2017-07-18
因為templateUrl模板所在的作用域在父級作用域$scope下,比如:
home-list.html內(nèi)容如下:
效果如下: