我有$scope.number = 1
。我想添加一个监听器来更新路径。
我的尝试不起作用:
function LocationController($scope, $location) {
$scope.$watch($scope.number, function(path) {
$location.path('/'+$scope.number);
});
}
另外,如何$scope.number
调用对象、子对象?
我有$scope.number = 1
。我想添加一个监听器来更新路径。
我的尝试不起作用:
function LocationController($scope, $location) {
$scope.$watch($scope.number, function(path) {
$location.path('/'+$scope.number);
});
}
另外,如何$scope.number
调用对象、子对象?
尝试
function LocationController($scope, $location) {
$scope.$watch('number', function(newNumber) {
$location.path('/'+newNumber);
});
}
阅读文档以获取参数$watch