-1

I have switched to angularJS framework and I have some issues with routing.

This is home.html view

<div id="home">
    <label for="priceStart">Kaina nuo:</label><input id="priceStart" type="number" />
    <label for="priceEnd">Kaina iki:</label><input id="priceEnd" type="number" />

    <input type="button" value="Restoranai" />
    <input type="button" value="Maisto tipai" />
    <input type="button" ng-click="navigateTo('/mealList');" value="Ieškoti" />
</div>

And this is home.js home controller

FoodSearchControllers.controller('homeCtrl', ['$scope', function($scope) {
    navigateTo = function(hash) {
        $location.hash(hash);
    };
}]);

Can anyone tell me why this doesnt work? Also, it would be good if someone can explain me how to pass variable's from home view to mealList view after this navigateTo() function is called.

4

1 回答 1

0

如果你使用 ng-click,你的函数应该以 $scope 开头。

FoodSearchControllers.controller('homeCtrl', ['$scope', '$location', function($scope, $location) {
    $scope.navigateTo = function(hash) {
        $location.hash(hash);
    };
}]);
于 2013-11-29T10:54:54.643 回答