欢迎您访问我爱IT技术网,今天小编为你分享的javascript教程:【angularJS 中$scope方法使用指南】,下面是详细的讲解!
angularJS 中$scope方法使用指南
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
</head>
<script src="http://www.jb51.net/article/http://localhost:81/js/jquery.js">
</script>
<script src="http://www.jb51.net/article/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>
关于angularJS 中$scope方法使用指南的用户互动如下:
相关问题:angularjs directive scope 怎么理解
答:今天我们要说的重点是 scope 字段。 常规用法设置 scope: { name: '=', age: '=', sex: '@', say: '&' } 假设我们的hml代码如下 对应的controller部分代码 function Controller($scope) { $scope.name = 'Pajjket'; $scope.age = 99; $scope.sex... >>详细
相关问题:angularjs self和$scope 区别
答:您好,这样的: 1,js代码 phonecatApp.controller('TestCtrl',['$scope','$rootScope', function($scope,$rootScope) { $rootScope.name = 'this is test'; } ]); phonecatApp.controller('Test111Ctrl',['$scope','$rootScope', function($sco... >>详细
相关问题:请教一个angularjs中在指令调用controller方法的问题
答:testvar myApp = angular.module("myApp", []); myApp.directive('testIt',function(){return {restrict: 'A',scope: false,link:function(scope, elm, attr){if(scope.$last){elm.css('color','red');scope.myFunction();}}} }); myApp.control... >>详细
- 【firefox】firefox浏览器不支持innerText的解决
- 【Extjs】Extjs学习过程中新手容易碰到的低级错误
- 【clearInterval】js clearInterval()方法的定义
- 【dom】javascript dom追加内容实现示例-追加内容
- 【checkbox】让checkbox不选中即将选中的checkbox
- 【Array】js中更短的 Array 类型转换-类型转换
- 【append】append和appendTo的区别以及appendChil
- 【ExtJs】ExtJs 表单提交登陆实现代码-表单提交-
- 【addClass】javascript自定义的addClass()方法
- 【Event】jquery下为Event handler传递动态参数的
- 评论列表(网友评论仅供网友表达个人看法,并不表明本站同意其观点或证实其描述)
-