Jam*_*s J 2 angularjs angularjs-routing
我试过在SO找到了多个解决方案,但我显然失去了一些东西作为不管什么我尝试,我不能让粒子视图来改变表单提交的(或点击按钮)的基础.
这是代码:
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');
}
}]);
Run Code Online (Sandbox Code Playgroud)
并在home.html部分
<input type="submit" class="topcoat-button--cta" value="Search">
Run Code Online (Sandbox Code Playgroud)
我的路由配置
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'
});
}]);
Run Code Online (Sandbox Code Playgroud)
有人能指出我正确的方向吗?文档似乎过于复杂,我发现的所有简单例子都做我正在做的事情......
字符串形式的参数与实际参数不匹配:
controller('HomeCtrl', ['$scope', 'SearchData', '$location',
function($scope, SearchData, $routeParams, $location)
Run Code Online (Sandbox Code Playgroud)
你之前忘了添加'$routeParams'数组'$location'.
| 归档时间: |
|
| 查看次数: |
5871 次 |
| 最近记录: |