AngularJs 使用 .value / .constant
2016-04-06 16:23
399 查看
app.js文件 angular.module('myApp', [ 'ngRoute', 'myApp.view1', 'myApp.view2', 'myApp.version' ]) .value('version', '5000') .value('testValue1', '10000') .constant('testValue2', '20000') .config(['$routeProvider', function($routeProvider) { $routeProvider.otherwise({redirectTo: '/view1'}); }]); view1.js 'use strict'; angular.module('myApp.view1', ['ngRoute']) .config(['$routeProvider', function($routeProvider) { $routeProvider.when('/view1', { templateUrl: 'view1/view1.html', controller: 'View1Ctrl' }); }]) .controller('View1Ctrl', ['$scope', 'version', 'testValue1', 'testValue2', function($scope, version, testValue1, testValue2) { console.log('version=' + version); console.log('testValue1=' + testValue1); console.log('testValue2=' + testValue2); }]);
相关文章推荐
- angularjs指令中link方法无法正确获取element
- Angularjs + Webpack 框架里,引入Bootstrap-datepicker插件时,datepicker is not a function错误的解决方法
- Why Angular2
- 过滤器
- 常用指令
- 控制器Controller
- MVVM简介
- angular入门
- angularJS中的ui-router和ng-grid模块
- 指令:ng-bind
- 指令:ng-model
- AngularJS
- 常用AngularJs代码段
- 常用AngularJs代码段
- [Angular 2] @ViewChild to access Child component's method
- 学习angular
- AngularJs
- angularjs post /get请求及radio button
- PhpStorm 对 AngularJS 的支持
- AngularJs 实战 -慕课网