JS
app.controller('categoryController', function($scope,$http){
$http.get('http://xxxxxxxxxxxx.com/public/api/v1/category').success(function(response){
$scope.myCategory = response.data;
});
$scope.showSubCategory = function(index) {
var selectedItem = $scope.myCategory[index];
var options = { animation: 'slide' };
$scope.myCategory.selectedItem = selectedItem;
$scope.ons.navigator.pushPage('subcategory.html', options, {name : selectedItem.name});
};
});HTML/Angular/Onsen
<ons-navigator>
<ons-page>
<ons-toolbar>
<div class="left">
<ons-toolbar-button ng-click="app.slidingMenu.toggleMenu()"><ons-icon icon="bars"></ons-icon></ons-toolbar-button>
</div>
<div class="center">Home</div>
<div class="right">
<ons-toolbar-button ng-click="app.slidingMenu.toggleMenu()"><ons-icon icon="fa-search"></ons-icon></ons-toolbar-button>
</div>
</ons-toolbar>
<ons-list ng-controller="categoryController" id="category-lists">
<ons-list-item modifier="chevron" class="item" ng-repeat="item in myCategory" ng-click="showSubCategory($index)">
<ons-row>
{{item.name}}
</ons-row>
</ons-list-item>
</ons-list>
</ons-page>
</ons-navigator>错误
TypeError:无法在file:///data/data/com.example.helloworld/files/projects/cloud/558d3c277e2193c742d69fea/www/components的file:///data/data/com.example.helloworld/files/projects/cloud/558d3c277e2193c742d69fea/www/components/loader.js:1439:30512的Scope.$scope.showSubCategory (file:///data/data/com.example.helloworld/files/projects/cloud/558d3c277e2193c742d69fea/www/components/app.js:16:27)调用未定义的方法“”pushPage“”在作用域应用。$ (file:///data/data/com.example.helloworld/files/projects/cloud/在作用域应用。$ /loader.js:1448:18904 (file:///data/data/com.example.helloworld/files/projects/cloud/558d3c277e2193c742d69fea/www/components/loader.js:1437:28433)在HTMLElement.listener eval558d3c277e2193c742d69fea/www/components/loader.js:1448:18886) at HTMLElement.eventHandler (file:///data/data/com.example.helloworld/files/projects/cloud/558d3c277e2193c742d69fea/www/components/loader.js:1441:13284) at FastClick.onTouchEnd (file:///data/data/com.example.helloworld/ ) at HTMLElement.eventHandler FastClick.sendClick at FastClick.onTouchEndHTMLBodyElement上的files/projects/cloud/558d3c277e2193c742d69fea/www/components/loader.js:1441:17447)。(file:///data/data/com.example.helloworld/files/projects/cloud/558d3c277e2193c742d69fea/www/components/loader.js:1441:10005)
您好,我使用过monaca.pushPage(subcategory.html,.....)没有错误,但不能移动到subcategory.html页面。
感谢您的帮助。
发布于 2015-06-29 10:19:39
ons变量不再存储导航器。您必须在导航器中使用var属性,并为其指定一个名称以在以后调用它。例如:
<ons-navigator var="myNavigator">
...
</ons-navigator>然后在myNavigator.pushPage(...)中使用它。更多信息请点击此处:http://onsen.io/reference/ons-navigator.html
希望它能帮上忙!
https://stackoverflow.com/questions/31085726
复制相似问题