Вопрос

I've tried multiple solutions found on SO but I'm obviously missing something fundamental as no matter what I try I cannot get the particle view to change on submission of a form (or click of a button).

Here's the code:

propertyControllers.controller('HomeCtrl', ['$scope', 'SearchData', '$location', 
function($scope, SearchData, $routeParams, $location) {

    SearchData.set('postcode', $scope.postcode);
    SearchData.set('radius', $scope.radius);
    SearchData.set('minBeds', $scope.minBeds);
    SearchData.set('minPrice', $scope.minPrice);

    $scope.submit = function() {
        $location.path('/properties');
    }

}]);

And in the home.html partial

<input type="submit" class="topcoat-button--cta" value="Search">

My routing config

    var propertyApp = angular.module('propertyApp', [
    'ngResource',
    'ngRoute',
    'propertyControllers'
]);

propertyApp.config(['$routeProvider',
    function($routeProvider) {
        $routeProvider.
        when('/home', {
            templateUrl: 'partials/home.html',
            controller: 'HomeCtrl'
        }).
        when('/properties', {
            templateUrl: 'partials/property-list.html',
            controller: 'PropertyListCtrl'
        }).
        when('/properties/:propertyId', {
            templateUrl: 'partials/property-detail.html',
            controller: 'PropertyDetailCtrl'
        }).
        otherwise({
            redirectTo: 'home'
        });

    }]);

Could someone point me in the right direction? The docs seem overly complex and all the simple examples I've found do what I'm doing...

Это было полезно?

Решение

The parameters in string form and the actual parameters don't match:

controller('HomeCtrl', ['$scope', 'SearchData', '$location', 
                function($scope, SearchData, $routeParams, $location)

You forgot to add '$routeParams' in the array, before '$location'.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top