zoukankan      html  css  js  c++  java
  • Angular 学习笔记——模块之间的通讯

    <!DOCTYPE HTML>
    <html ng-app="myApp">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>无标题文档</title>
    <script src="angular.min.js"></script>
    <script>
    var m1 = angular.module('module1',[]);
    // m1.factory('myService',function (){
    //     return{
    //         name:'hello',
    //         show:function(){
    //             return this.name + ':angular';
    //         }
    //     };
    // });
    
    m1.provider('myService',function(){
        return{
            name:'hello',
            $get:function(){
                return{
                    name:this.name,
                    show:function(){
                        return this.name + ':angular'
                    }
                }
            }
        }
    })
    var m2 = angular.module('myApp',['module1']);
    
    m2.controller('Aaa',['$scope','myService',function($scope,myService){
        console.log(myService.show())
    }])
    </script>
    </head>
    
    <body>
    <div ng-controller="Aaa">
       
    </div>
    </body>
    </html>
  • 相关阅读:
    正向代理和反向代理
    Unicode
    utf-8
    ISO 8895-1
    ProtocalBuffers学习记录
    C#基础知识
    MSBuild学习记录
    Linux学习笔记
    Jenkins学习记录
    CruiseControl.Net学习记录
  • 原文地址:https://www.cnblogs.com/mayufo/p/5031585.html
Copyright © 2011-2022 走看看