angular js module 的理解
2024-09-04 10:32:19
module其实就是一个容器,里面可以装controller,service,directive,filter等,
官网的解释是:Module :A container for the different parts of an app including controllers,services,filters,and directives which configures the injector.
下面的例子中定义了两个angular.module,其中第二个module,依赖第一个module,引用第一个module中的filter方法:
例子的代码如下:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<script src="../materialDesignfile/angular.js"></script>
<script>
angular.module("myApp",[])
.filter("greeting",function () {
var ouyangfeng=function (name) {
debugger
return "Hello "+name;
}
return ouyangfeng;
});
angular.module("myApp2",['myApp']).controller("myCtrl",['greetingFilter','$scope',function (greetingFilter,$scope) {
$scope.name=greetingFilter("欧阳凤");
}]);
</script>
<div ng-app="myApp2" ng-controller="myCtrl">
<h1>{{name}}</h1>
</div>
</body>
</html>
最新文章
- Box-sizing:小身材,大拳头!
- Spring配置c3p0数据源时出错报:java.lang.NoClassDefFoundError: com/mchange/v2/ser/Indirector
- HttpContextBase转换成HttpContext对象
- ASP.NET MVC 学习之路由(URL Routing)
- HD1556Color the ball(树状数组)
- jquery mousewheel
- winform Label与DataGridView右对齐 分类: WinForm 2014-05-19 20:51 446人阅读 评论(0) 收藏
- DoNet开源项目-基于Amaze UI的点餐系统
- Html 语法学习笔记二
- java实现大数相加问题
- svn地址如何更改
- redux+saga+reducer
- linq总结系列(一)---基础部分
- java JDBC (八) 连接池 DBCP
- windows(cr lf )转unix (lf)
- jquery实现根据所选时间生成页面元素
- CentOS7服务器添加新用户
- git初级浅入其常用操作
- ppt 文字按笔画进入。
- Microsoft Power BI Desktop概念学习系列之Microsoft Power BI Desktop的下载和安装(图文详解)
热门文章
- 算法竞赛入门经典-1.5.4 Q&;A
- java时间";yyyy-mm-dd HH:mm:ss";转成Date
- 如何在WIN7_64环境下安装Oracle10g_64位版本
- jetbraints激活码
- git使用ssh密钥(转)
- 在spring+beranate中多数据源中使用 ThreadLocal ,总结的原理 --费元星
- cordova 框架下开发app推送
- python发起请求提示UnicodeEncodeError
- 怎样安装PyCharm
- Assetbundle2