zoukankan      html  css  js  c++  java
  • angular 1.6路由

    angular.js 1.6版本;
    1.实例化:
    var app = angular.module('app',[]).controller('myapp',['$scope',function ($scope){}]);


    2-1.原生路由:


    <a href="#/home"></a>
    <div ng-view></div>
    1> 注入var app = angular.module('app',[ngRouter])
    2> 配置app.config(['$routerProvider','$locationProvider',function($routerProvider,$locationProvider){
    $locationProvider.hashPrefix('');//1.6版本变化;
    $routerProvider
    .when('/index'{
    templateUrl:"./index.html",
    controller:"con"
    })
    .otherwise({redirectTo:"/index"});
    }])


    2-2.ui-router


    ng-view => ui-view
    <a href="#/home"></a>
    <div ui-view></div>
    1> 模块注入:
    var app = angular.module('app',['ui.router']);
    2> 配置路由
    app.config(['$stateProvider','$locationProvider','$urlRouterProvider',function($stateProvider,$locationProvider,$urlRouterProvider){
    $locationProvider.hashPrefix('');
    $urlRouterProvider.otherwise('/index');
    $stateProvider.state('home',{
    url:"/home",
    templateUrl:"./home.html",
    controller:function(){}
    })
    }])
    3.过滤器
    app.filter('test',function(){
    return function(input){
    //code...
    }
    })

  • 相关阅读:
    linux 修改文件夹颜色 终端颜色
    每日更新FadeTop背景为必应图片
    odoo 去除动作菜单的删除按钮
    crontab详解
    odoo 创建初始数据库 切换当前数据库
    python for else
    lfi phpinfo
    python __dict__
    iscsi 开机自动挂载
    HP SSD smart path
  • 原文地址:https://www.cnblogs.com/ade-Java/p/6523862.html
Copyright © 2011-2022 走看看