推送页面无法正常工作 - 温泉摩纳卡电话间隙



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/角度/开启

  <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:无法调用未定义的方法"pushPage"范围内$scope.showSubCategory(file:///data/data/com.example.helloworld/files/projects/cloud/558d3c277e2193c742d69fea/www/components/app.js:16:27)在file:///data/data/com.example.helloworld/files/projects/cloud/558d3c277e2193c742d69fea/www/components/loader.js:1439:30512在file:///data/data/com.example.helloworld/files/projects/cloud/558d3c277e2193c742d69fea/www/components/loader.js:1448:18904范围内$eval(file:///data/data/com.example.helloworld/files/projects/cloud/558d3c277e2193c742d69fea/www/components/loader.js:1437:28127)范围内$应用(file:///data/data/com.example.helloworld/files/projects/cloud/558d3c277e2193c742d69fea/www/components/loader.js:1437:28433)位于HTMLElement.listener(file:///data/data/com.example.helloworld/files/projects/cloud/558d3c277e2193c742d69fea/www/components/loader.js:1448:18886)位于HTMLElement.eventHandler(file:///data/data/com.example.helloworld/files/projects/cloud/558d3c277e2193c742d69fea/www/components/loader.js:1434:29261)在FastClick.sendClick(file:///data/data/com.example.helloworld/files/projects/cloud/558d3c277e2193c742d69fea/www/components/loader.js:1441:13284)在FastClick.onTouchEnd(file:///data/data/com.example.helloworld/files/projects/cloud/558d3c277e2193c742d69fea/www/components/loader.js:1441:17447)在HTMLBodyElement上。(file:///data/data/com.example.helloworld/files/projects/cloud/558d3c277e2193c742d69fea/www/components/loader.js:1441:10005)


嗨,我使用了monaca.pushPage(subcategory.html,…..),没有错误,但无法移动到subcategore.html页面

感谢您的帮助。

ons变量不再存储导航器。您必须在导航器中使用var属性,并为其指定一个名称以便以后调用。例如:

<ons-navigator var="myNavigator">
    ...
</ons-navigator>

然后将其与myNavigator.pushPage(...)一起使用。更多信息请点击此处:http://onsen.io/reference/ons-navigator.html

希望它能有所帮助!

相关内容

  • 没有找到相关文章

最新更新