草庐IT

auto-watch

全部标签

javascript - jsx --watch 将 jsx 语法转换为小写 "react"而不是大写 "React"

我在这里松散地关注facebooksReact教程,http://facebook.github.io/react/docs/getting-started.html,但我将其应用于不同的html文件。这是我的html文件,基于React入门工具包:HelloReact我安装了react-tools,现在当我运行“jsx--watchsrc/build/”它正在转换这个片段:varCommentBox=React.createClass({render:function(){return(Hello,world!IamaCommentBox.);}});React.renderComp

javascript - 在 Controller 中使用 `this` 作用域时使用 $scope.$watch

我的Angular应用程序中有一个Controller:(function(angular){functionMyController(){this.name='Dave';//Iwanttohavecodelikethis:/*$scope.$watch('name',function(newValue,oldValue){console.log(oldValue,"changedto",newValue);});*/}window.myApp=angular.module('myApp',[]).controller('MyController',[MyController]);}

javascript - async.auto 中的任务结果

我对async.auto中从一项任务到另一项任务的结果逻辑感到困惑。.例如,在下面的代码逻辑中,我在task1中向模型添加了一些数据,它最初是initialtask的输出,在finalTask​​中添加了数据到task1中的模型也反射(reflect)在results.initialTask​​1中。task2中类似添加的数据反射(reflect)在finalTask​​中的results.initialTask​​1中。总结所有results.initialTask​​1,results.task1[0],results.task2[0]、results.task3[0]在final

javascript - 光标 :auto behaviour in IE 8 and 9

我想要的是为整个body标签指定cursor:pointer,这样页面的背景是可点击的,但我也希望页面的其余部分像它那样工作,所以我尝试为div设置cursor:auto,其中包含页面。在FF、Chrome和safari中,它工作正常,在IE6和7中也是如此。但似乎IE8和9以及(去他的)OPERA对cursor:auto的含义有自己的看法。这是一个片段,看看会发生什么:CursortestThisisaparagraphclickhere.虽然这是一个HTML片段,但所有内容都是使用javascript完成的,结果相同。该标准说的有些含糊:用户代理根据当前上下文确定要显示的光标。,这

javascript - body 元素的左侧和顶部偏移量为 :auto

我正在尝试通过使用margin:autoCSS属性获取一个网站的鼠标相对于body(即body=坐标原点)的位置,该网站的body元素大小固定并居中。由于event.clientX和event.clientY属性为我提供了从页面开头开始的偏移量,而不是从body元素开始的偏移量,因此我尝试将其减去body偏移量。为此,我尝试使用document.body.offsetLeft和document.body.offsetTop,但到目前为止运气不好,该值未定义。另外,因为我没有定义它,所以我不能使用document.body.style.left或document.body.style.t

javascript - angular js 在 watch 语句中恢复范围属性的更改

我有一个选择框,当它发生变化时会触发一个httpPUT。html:js:$scope.$watch('color',function(newValue,oldValue){$http.put('...',{color:newValue})});问题是,如果http请求因任何原因失败,我希望选择框恢复到它以前的值。$scope.$watch('color',function(newValue,oldValue){req=$http.put('...',{color:newValue})req.error(function(){$scope.color=oldValue//willprob

javascript - $scope.$watch in Angular 在 Ionic/Cordova 中不起作用

我正在使用IonicFramework构建应用程序我现在想为此创建一些开关(基本上是花哨的复选框)。当有人按下开关时,我想将其发送到服务器,因此我首先trycatch开关更改事件。在基本的Angular安装中,我在html()和$watch中使用一个简单的复选框进行了尝试。在我的Controller中像这样:$scope.$watch('theswitch',function(){console.log('theswitchchanged');if($scope.boel){console.log('theswitchisTRUE');}else{console.log('theswi

javascript - Angular : Watch Service for data changes?

我有一个定义如下的服务:appServices.service('SharedData',function(){vardata={};functionsetContacts(contacts){data.contacts=contacts;};functiongetContacts(){returndata.contacts;};return{setContacts:setContacts,getContacts:getContacts};});在另一个Controller中,我按如下方式访问数据:$scope.contacts=SharedData.getContacts();一切都

javascript - Angular $watch 不工作

我在我的Controller上使用了两个$watches来观察这两个对象:$scope.gastos={name:"Gastosmensuales",data:[0,0,0,0,0,0,0,0,0,0,0,0],labels:["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"]};$scope.ganancias={name:"Gananciasmensuales",data:[0,0,0,0,0,0,0,0,0

javascript - Grunt Live-Reload 通过 Watch

我正在尝试配置grunt以在更改时实时加载js和less/css文件。虽然grunt确实正确地“监视”并执行分配的任务,但它不会实时重新加载文件。下面是我的配置,有人看到有什么问题吗?module.exports=function(grunt){grunt.initConfig({pkg:grunt.file.readJSON("package.json"),jshint:{files:["Gruntfile.js","src/javascripts/**/*.js"],options:{globals:{jQuery:true,console:true,module:true}}},