简体   繁体   English

角度ui引导程序,$ scope。$ watch不起作用

[英]angular ui bootstrap, $scope.$watch doesn't work

I'm playing with angular datekeeper, and trying to set basic function of $watch which will show me, some information in console.log. 我正在与角度日期守卫一起玩,并尝试设置$ watch的基本功能,该功能将向我显示console.log中的一些信息。 This function should show to me if my date is lesser than my maxDate so show me in console "wrong date". 如果我的日期小于我的maxDate,则应该向我显示此功能,因此请在控制台“错误的日期”中向我显示。 I've read a documentation about $watch but couldn't figure out. 我已经阅读了有关$ watch的文档,但不知道。 What am i doing wrong? 我究竟做错了什么? this is link on enter code here plunker 这是链接enter code here plunker

You don't need the $scope. 您不需要$ scope。 in front of dt in your watch 在手表的dt前面

$scope.$watch ('$scope.dt', function(){
    if($scope.dt < $scope.maxDate){
      console.log('wrong date')
    }
  })

should be: 应该:

$scope.$watch ('dt', function(){
    if($scope.dt < $scope.maxDate){
      console.log('wrong date')
    }
  })

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM