Angular 学习笔记——service &constant
2024-08-28 17:10:37
<!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>
最新文章
- 进程监控工具supervisor 启动Mongodb
- ARM的常数表达式
- es6+移动轮播插件
- 使用Form Builder创建Form具体步骤
- ubuntu下firefox无法看bilibili解决方案
- 安装python官方的mysql库“mysql-connector-python”
- iOS代码规范文档
- IE6不支持<;a>;标签以外元素的hover的解决方案
- Python+Selenuim测试网站,只能打开Firefox浏览器却不能打开网页的解决方法
- MySQL模糊查询中通配符的转义
- GCJ-02火星坐标系和WGS-84坐标系转换关系
- 动态生成table 列
- Zoomit的用法总结
- 未能加载文件或程序集“System.Web.Http.WebHost, Version=4.0.0.0, ”或它的某一个依赖项。系统找不到指定的文件。
- 20135202闫佳歆--week5 课本18章学习笔记
- Hibernate Annotation 设置字段的默认值
- Sketch Up常见问题
- win7 64位机ODBC的数据源DSN添加和移除问题
- require-ensure
- 关于swagger文档的使用方法