首页 > 其他分享 >angular的$scope,这东西满重要的

angular的$scope,这东西满重要的

时间:2023-01-13 15:36:17浏览次数:32  
标签:function return 东西 app tag scope angular

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>


<script src="http://localhost:81/js/jquery.js">
</script>
<script src="http://localhost:81/js/angular.min.js">
</script>

</head>
<body ng-app="app" ng-controller="c">
<div ng-show="tag">1111</div>
<!--
<button ng-click="F()">showOrHide</button>
-->
<button t>1</button>
<script>
var app = angular.module("app",[]);
function c($scope){
$scope.tag = false;
$scope.F = function(){
$scope.tag = !$scope.tag;
}
};
app.directive("t",function(){
return {
compile : function($compile){
return function($s,$e,$a,$c){
$e.on("click",function(){
//左右在$scope的作用域下执行,才能享受到模型和视图改变的优势;
$s.$apply(function(){
$s.tag = !$s.tag
})
})
}
}
}
})
</script>
</body>
</html>

  

天道酬勤



标签:function,return,东西,app,tag,scope,angular
From: https://blog.51cto.com/u_12304260/6006066

相关文章

  • angular_$attrs
    <!doctypehtml><html><head><metacharset="utf-8"><title>无标题文档</title><scriptsrc="http://localhost:81/j......
  • angular-input
    <!doctypehtml><html><head><metacharset="utf-8"><title>无标题文档</title></head><scriptsrc="http://localhost:81/js/jquery.js"></script><scriptsrc="http://loc......
  • angular_form
    <!doctypehtml><html><head><metacharset="utf-8"><title>无标题文档</title></head><scriptsrc="http://localhost:81/js/jquery.js"></script><scriptsrc="http://loc......
  • angular学习-入门基础
    angular所有用到的库,全部用的CDN:运行下面代码<scriptsrc="http://cdn.bootcss.com/jquery/2.1.1/jquery.js"></script><scriptsrc="http://cdn.bootcss.com/an......
  • angular-scope.assign
    <!doctypehtml><html><head><metacharset="utf-8"><title>无标题文档</title></head><scriptsrc="http://localhost:81/js/jquery.js"></script><scriptsrc="http://loc......
  • angular的DEMO(用来练习和顺便看看)
    inflector(辅助) 将用户输入的字符串转化成驼峰或者空格或者底线的小插件;这个是一个小的过滤器,平常也是用不到的,合格是过滤器的代码:app.filter("inflector",......
  • angular的编辑器tinymce
    angular的插件的确挺少的,编辑器更是少,ui-tinymce是angular-ui推荐的一款编辑器​​(GIT:https://github.com/angular-ui/ui-tinymce)​​;效果图通过n......
  • angular实例教程(用来熟悉指令和过滤器的编写)
    angular的插件太少了, 所以很多指令和过滤器都要自己写, 所以对指令传进来的参数,以及angular编译的流程更加熟悉才行写出好的插件,有些简单的指令是参考​​angu......
  • angular的工具方法笔记(equals, HashKey)
    分别是angular脏值检测的工具方法equals和类HashKey的使用方法<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml......
  • angular的canvas画图例子
    angular的例子:<!DOCTYPEhtml><htmlng-app="APP"><head><metacharset="UTF-8"><scriptsrc="http://cdn.bootcss.com/angular.js/1.3.0-beta.12/angular.min.js"></......