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>
  • 相关阅读:
    java——对象学习笔记
    ORACLE中如何查看分区表信息
    postgresql相关系统表查询
    oracle系统表查询
    linux shell常用函数,ps
    文本文件合并
    nginx多版本PHP配置
    webuploader实现文件上传
    open abc.txt: The system cannot find the file specified
    PHP在线批量下载文件
  • 原文地址:https://www.cnblogs.com/mayufo/p/5031602.html
Copyright © 2011-2022 走看看