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>
  • 相关阅读:
    LeetCode-6 ZigZag Conversion
    求两个字符串的最长公共子串
    Eclipse 添加 javap
    时间复杂度
    leetcode oj-3
    Android Rom分区 与 SD卡读写
    论文首次处理流程及代码
    论文片段
    项目整体流程
    春晚项目中的相关脚本
  • 原文地址:https://www.cnblogs.com/1540340840qls/p/7826024.html
Copyright © 2011-2022 走看看