2

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

1
  • Get your HomeCtrl dependencies straight. Commented Feb 22, 2014 at 11:29

1 Answer 1

5

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

Sign up to request clarification or add additional context in comments.

1 Comment

Wow, embarrassing! Can't believe I missed that!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.