我想通过在输入字段中小费来动态更改我的angularjs app中的url.
例如
http://localhost/test/year/2012http://localhost/test/year/2013 http://localhost/test/year/2012/?year=2013我的模块配置.
var module = angular.module('exampleApp').
config(['$routeProvider', function ($routeProvider) {
$routeProvider.
when('/test/year/:year', {templateUrl: 'partials/test.html', controller: OverviewCtrl, reloadOnSearch: false}).
otherwise({redirectTo: '/'});
}]);
Run Code Online (Sandbox Code Playgroud)
控制器动作:
function OverviewCtrl($scope,$routeParams, $location) {
$scope.yearIsChanged = function () {
$location.search('year', $scope.year);
}
}
Run Code Online (Sandbox Code Playgroud)