angularJS 中$scope方法使用指南
更新時間:2015年02月09日 10:56:43 投稿:hebedich
這篇文章主要介紹了angularJS 中$scope方法使用指南,需要的朋友可以參考下
復制代碼 代碼如下:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>無標題文檔</title>
</head>
<script src="http://localhost:81/js/jquery.js">
</script>
<script src="http://localhost:81/js/angular.min.js">
</script>
<body ng-app="app" ng-controller="c">
<div dir ng-repeat="item in items" ng-model="m">
{{item}} + {{m}} <br>
</div>
</body>
<script>
var app = angular.module("app", []);
function c($scope){
$scope.items = [1,2,2,3,4,5,5];
$scope.m = "string";
};
app.directive("dir",function($parse){
return {
compile : function( $compile ){
return function(s,e,a){
//what .. ..
//a.ngModel
//用$("xxx").scope.xx = model
//assign 分配
//console.log( $parse( a.ngModel ).assign(s,"sdfs__________newValue__________dfd") )
s.m = "sdfs____#@$#@$#@$@#$__dfd這兩個效果一摸一樣";
}
}
}
});
</script>
</html>
以上就是關(guān)于angularJS 中$scope方法使用指南的全部內(nèi)容了,希望大家能夠喜歡。
相關(guān)文章
Angular2 Service實現(xiàn)簡單音樂播放器服務(wù)
本篇文章主要介紹了Angular2 Service實現(xiàn)簡單音樂播放器服務(wù) ,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-02-02AngularJS中$apply方法和$watch方法用法總結(jié)
這篇文章主要介紹了AngularJS中$apply方法和$watch方法用法,結(jié)合實例形式總結(jié)分析了$apply方法和$watch方法的功能、參數(shù)含義、使用技巧與相關(guān)注意事項,需要的朋友可以參考下2016-12-12Angular依賴注入optional?constructor?parameters概念
這篇文章主要為大家介紹了Angular?依賴注入領(lǐng)域里?optional?constructor?parameters?的概念及使用,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2023-11-11Angular 理解module和injector,即依賴注入
本文主要介紹Angular 理解module和injector的知識,這里整理了相關(guān)知識,并詳細介紹了依賴注入的問題,有興趣的小伙伴可以參考下2016-09-09angularJs中$scope數(shù)據(jù)序列化的實例
今天小編就為大家分享一篇angularJs中$scope數(shù)據(jù)序列化的實例,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2018-09-09angular.js和vue.js中實現(xiàn)函數(shù)去抖示例(debounce)
這篇文章主要介紹了angular.js和vue.js中實現(xiàn)函數(shù)去抖示例(debounce),小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2018-01-01