监听服务
语法:$scope.$watch(‘要监听的数据',function(n,o){})
说明:①.这个服务是$scope作用域对象上的一个方法,不需要单独注入
②.这个方法能监听页面中任何数据的改变,监听时会保存监听对象的旧值和新值。
作用:监听数据改变后 触发事件
<input type="text" ng-model='msg'>
<p>{{msg}}</p>
<script>
var app=angular.module('app',[]);
// 监听 服务
app.controller('main',['$scope','$location',function($scope,$location){
// $scope.msg='';
// //监听数据改变
// $scope.$watch('msg',function(n,old){
// console.log(n,old);
// })
//location
console.log($location);
console.log($location.$$absUrl);
console.log($location.absUrl());
}])
</script>