草庐IT

grunt-contrib-watch

全部标签

javascript - ng-click 与 Angular 中的 watch

我有一个加载JSON文件然后使用该数据创建HTML5Canvas绘图的指令(即json数据包含文本、颜色、位置等内容)。我还有许多输入字段(文本、slider等),允许用户操作绘图。我看到我可以$watch这些元素中的每一个或使用ng-click并调用一个函数-有推荐的方法吗?一些可能相关的注释:表单元素和Canvas都是同一个指令模板的一部分表单元素对变化使用react,因此没有提交按钮这些表单元素值中的每一个都经过检查,可能会进行转换,然后修改json字符串。然后我调用一个刷新函数,用新数据重新加载我的Canvas。我也有可能以错误的方式处理这个问题......

javascript - grunt.task.run() 不工作

我正在尝试在我的express应用程序中使用grunt。我有这样的东西:vargrunt=require('grunt');require(process.cwd()+'/gruntfile.js')(grunt);grunt.task.run('development');但是这个任务好像不行。(没有错误输出到控制台)但是,如果我直接在控制台“gruntdevelopment”中运行,它就可以正常工作。 最佳答案 grunt.task.run只是将一个任务添加到队列中,因此它可以在现有任务中运行,但不能在外部脚本中运行。这是我从g

javascript - Grunt imagemin - 观看多个文件/文件夹优化单个文件?

是否可以使用grunt-contrib-imagemine和grunt-contrib-watch查看多个文件/文件夹但只优化单个文件?我这样试过:(gruntfile的一部分)imagemin:{dist:{cwd:'images/modules',files:['images/modules/**/*.{png,jpg,gif}'],dest:'images/modules'}},watch:{images:{files:['images/modules/**/*.{png,jpg,gif}'],tasks:['imagemin'],options:{spawn:false,}}}

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 - 如何使用 grunt autoprefixer 定位 IE9 及更高版本?

如何使用gruntautoprefixer针对IE9及更高版本?我可以做类似以下的事情吗:grunt.config('autoprefixer',{options:{browsers:['IE9+']},dist:{expand:true,src:'/styles/app.css'}}); 最佳答案 browsers选项的语法可以在主Autoprefixerdocumentation中找到。.相关位是:Firefox>=20isFirefoxversion20ornewer.和:Browsersnames(caseinsensiti

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 - 如果缺少输入文件,是否有办法导致 Grunt 插件失败?

我一直在使用Gruntcssminplugin.我的Gruntfile中有一个block,大致如下所示:cssmin:{target:{files:{'/mytarget.css':['bower_components/normalize.css/*.css','bower_components/html5-boilerplate/css/main.css','/css/*.css']}}}有一段时间这工作正常;但是我将它移到了另一台机器上并且没有正确设置我的Bower组件-html5-boilerplate/css/main.css文件丢失了-但任务仍然成功完成。事实上,我可以将完全

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();一切都