1
我在两个diff代码中获取两个流。 我正在开发基于ionicframework的应用程序,使用其默认(基于角度的ui-router
)路由。 现在,当我编码离子这种方式。如何在IonicFramework中只加载所需的模板
*.config(["$stateProvider","$urlRouterProvider",function ($stateProvider,$urlRouterProvider) {
$urlRouterProvider
.otherwise('oops');
$stateProvider
.state('dashboard',{
url:"/dashboard",
abstract: true,
templateUrl:'templates/dashboard.html',
controller:"myCtrl"
})
.state('courses',{
url:'/courses',
templateUrl:'templates/courses.html',
controller:'myCtrl'
})
.state('transactions',{
url:'/transactions',
templateUrl:'templates/transactions.html'
})
.state('oops',{
url:'/oops',
templateUrl:'templates/oops.html',
controller:'myCtrl'
})
}])*
观点:
<ion-nav-view></ion-nav-view>
我发现我的所有模板都得到加载一次(在浏览器控制台测试),当我把我的基本路线(也可用于任何路线,无论我呼吁第一加载的应用程序)。
其中,当我使用UI-路由器的非离子型的应用等:
myApp.config(function($stateProvider,$urlRouterProvider){
/*throw the rest url to home page*/
$urlRouterProvider.otherwise("/single");
$stateProvider
.state("single",{
url:"/single",
templateUrl:"templates/single.html"
})
.state("portfolio",{
url:'/portfolio',
templateUrl:'templates/portfolio.html',
controller:"myCtrl"
})
.state("nested",{
url:"/nested",
templateUrl:"templates/nested.html"
}
)
.state("nested.viwe1",{
url:"/view1",
templateUrl:"templates/nested.view1.html"
})
.state("nested.viwe2",{
url:"/view2",
templateUrl:"templates/nested.view2.html"
})
});
视图:
<div ui-view class="my-element"></div>
仅要求模板(与路线配置的),是越来越加载。 因此,Ionic最初加载所有模板,否则我的代码错误。