angularjs积累

前端之家收集整理的这篇文章主要介绍了angularjs积累前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

注册 ui-router
注入 $stateParams

app.js配置
var App = angular.module('app',['ui.router']);
App.config(
    $state.Provider.state("history"{
        url:"/history/:id",views:{
            "":{
                templateUrl:"../tpls/history.html",controller:"historyController"
            }
        }
    )
)
//controller中使用
App.controller("history",function($state,$stateParams){
    $state.go('.',{id:1},{reload:true});
    console.log($stateParams.id);
})
//HTML页面中国年使用(跳转到本页面,带参数id=1,刷新页面)
<a ui-sref="history({id:1})">跳转到history页面</a>

猜你在找的Angularjs相关文章