2
我尝试了多种解决方案,但我显然错过了一些基本的东西,无论我尝试什么,我都无法获取粒子视图以进行更改提交表单(或点击按钮)。
下面的代码:
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');
}
}]);
而在home.html
部分
<input type="submit" class="topcoat-button--cta" value="Search">
我的路由配置
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'
});
}]);
有人能指出我在正确的方向?该文档似乎过于复杂和所有我已经找到了简单的例子,做我在做什么...
直接获得你的'HomeCtrl'依赖关系。 – Stewie