zoukankan      html  css  js  c++  java
  • Angular 学习笔记——service &constant

    <!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('myApp',[]);
    m1.service('myService',FnService);
    function FnService(){
        this.name = 'hello'
    }
    FnService.prototype.age = 20;
    
    m1.controller('Aaa',['$scope','myService',function($scope,myService){
            console.log(myService.name);
    }])
    
    </script>
    </head>
    
    <body>
    <div ng-controller="Aaa">
       
    </div>
    </body>
    </html>
    <!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('myApp',[]);
    // m1.service('myService',FnService);
    // function FnService(){
    //     this.name = 'hello'
    // }
    // FnService.prototype.age = 20;
    
    m1.constant('myService','hello angular11');
    
    m1.config(['myService',function(myService){
        console.log(myService);
    }])
    m1.controller('Aaa',['$scope','myService',function($scope,myService){
            console.log(myService);
    }])
    
    </script>
    </head>
    
    <body>
    <div ng-controller="Aaa">
       
    </div>
    </body>
    </html>
  • 相关阅读:
    【Leetcode】113Path Sum II
    【leetcode】112. Path Sum
    virtualbox 中安装win7虚拟机
    制作一个vagrant的win7 box
    socket编程
    异常处理
    strip(),replace()和re.sub()用法
    面象对象 高阶篇
    面象对象 基础篇
    Subprocess模块介绍
  • 原文地址:https://www.cnblogs.com/mayufo/p/5031602.html
Copyright © 2011-2022 走看看