[AngularJS] Config(), run(), when(); otherwise();
angularjs config when run
2023-09-14 08:59:21 时间
var app = angular.module("app", ["ngRoute"]); app.config(function ($routeProvider) { $routeProvider .when('/', { // file:///C:/Users/Answer1215/WebstormProjects/angular/angular_config/index.html#/ template: "Yum!!" }) .when('/pizza', { This shoule be in front of /:message // file:///C:/Users/Answer1215/WebstormProjects/angular/angular_config/index.html#/pizza template: "Welcome to my country" }) .when('/:message', { // file:///C:/Users/Answer1215/WebstormProjects/angular/angular_config/index.html#/hollo template: "{{model.message}}", controller: "AppCtrl" }).when('/:country/:state/:city', { //file:///C:/Users/Answer1215/WebstormProjects/angular/angular_config/index.html#/china/shanghai/pudong template: "{{country.message}}", controller: "AppCtrl" }) .when('/:country/:state/:city/:err', { // file:///C:/Users/Answer1215/WebstormProjects/angular/angular_config/index.html#/china/shanghai/pudong/dezhou?zoom=3 redirectTo: function (routeParams, path, search) { console.log(routeParams); console.log(path); ///china/shanghai/pudong/dezhou console.log(search); //{zoom: 3} // If meet stuitaions which not quite understand, send it back to the location you want return "/" + routeParams.country + "/" + routeParams.state + "/" + routeParams.city; } }) .otherwise({ redirectTo: "/" }); }) ; app.controller("AppCtrl", function ($scope, $routeParams) { $scope.model = { message: $routeParams.message } $scope.country = { message: $routeParams.country + ", " + $routeParams.state + ", " + $routeParams.city } });
相关文章
- Angularjs学习---官方phonecat实例学习angularjs step0 step1
- Angularjs学习---angularjs环境搭建,ubuntu 12.04下安装nodejs、npm和karma
- [AngularJS] Interpolation fail in IE 11
- [AngularJS] Isolate State Mutations in Angular Components
- [AngularJS] Using $parse Service
- [AngularJS] Best Practise - Minification and annotation
- [AngularJS] Angular 1.3 ng-model-options - getterSetter
- [AngularJS] Promises. 3. config().when() -- resolve: {doFisrt: ....., doSecond: ....}
- [AngularJS] Promises in config. 2. config().when()
- Angularjs学习---官方phonecat实例学习angularjs step0 step1
- Angularjs学习---ubuntu12.04中karma安装配置中常见的问题总结
- [AngularJS] Using $parse Service
- [AngularJS] AngularJS $cacheFactory service
- [AngularJS] Reusable directive, require from parent controller
- [AngularJS] Using $anchorScroll
- [AngularJS] Using the LocalForage library for offline storage with Angular
- [Angularjs]过滤器