2

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/温泉

  <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>

错误

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) 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) 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) 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) 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, .....) 并且没有错误,但无法移动到 subcategory.html 页面。

任何帮助表示赞赏。

4

1 回答 1

0

ons变量不再存储导航器。您必须var在导航器中使用属性并为其命名以便之后调用它。例如:

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

然后将其与myNavigator.pushPage(...). 更多信息在这里: http: //onsen.io/reference/ons-navigator.html

希望能帮助到你!

于 2015-06-29T02:19:38.667 回答