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>
  • 相关阅读:
    异或(^/XOR)的研究
    FastJson的使用
    KindEditor使用
    Java之Collection一
    Java之String
    Github基本使用
    Ubuntu jekyll git使用小记
    使用html editor 打开freemarker文件
    struts.xml 标签顺序
    multipart/form-data ajax 提交问题(未解决)
  • 原文地址:https://www.cnblogs.com/1540340840qls/p/7826024.html
Copyright © 2011-2022 走看看