zoukankan      html  css  js  c++  java
  • angular js module 的理解

    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>
  • 相关阅读:
    关于编码的问题(转)
    XML巩固
    浏览器兼容问题的解决方案
    JavaScript 全局变量命名空间生成函数
    表格的使用(转)
    post上传文件
    安装cocoapods
    UILabel内容模糊
    动态获取键盘高度
    iOS多线程同步锁
  • 原文地址:https://www.cnblogs.com/1540340840qls/p/7826024.html
Copyright © 2011-2022 走看看