Angular 学习笔记——service constant
生活随笔
收集整理的這篇文章主要介紹了
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>?
轉載于:https://www.cnblogs.com/mayufo/p/5031602.html
總結
以上是生活随笔為你收集整理的Angular 学习笔记——service constant的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Centos root权限的变化
- 下一篇: OceanBase如何解决支付宝数据库的