我试图填充一个ion-content
容器。我想HTML加载到$scope
取决于哪个选项卡用户点击:
<ion-tabs tabs-type="tabs-icon-only">
<ion-tab ...>
<ion-tab title="Create" icon-on="ion-android-create">
<ion-content padding="true" class="has-header">
{{getCreate}}
</ion-content>
</ion-tab>
<ion-tab ...>
</ion-tabs>
这是此视图中的控制器:
(function() {
'use strict';
angular.module('ionicApp')
.controller('HomePageController', ['$scope', '$state', '$templateCache', HomePageController]);
function HomePageController($scope, $state, $templateCache) {
$scope.getCreate = function() {
// at the moment create.html is just simple static html.
return $templateCache.get('app/views/home/ads/create.html');
//return $templateCache.get('main.create'); // this also doesn't work
};
}
})
();
的两个相关的状态被定义为:
.state('main.home', {
url: '/home',
views: {
'main': {
templateUrl: 'app/views/home/home.html',
controller: 'HomePageController'
}
}
})
.state('main.create', {
url: '/create',
views: {
'main': {
templateUrl: 'app/views/home/ads/create.html',
controller: 'CreateAdController'
}
}
})
我对此有错吗?在我的HomePageController
中,我需要做什么才能将create.html
加载到$scope.getCreate
?
这是* *几乎完美,除了线' '创造':{'。当我指定视图名称创建时,它不起作用,但是当我使用'main'时,它确实如此。任何想法为什么? – DaveDev
嗯,不确定。我比'Ionic版本更熟悉'angular-ui-router'。很高兴帮助:) –