watch

Angularjs watch service object

浪子不回头ぞ 提交于 2019-12-02 23:37:34
Why can't I watch a object in a service. Ive got a simple variable working, but a object wont work. http://plnkr.co/edit/S4b2g3baS7dwQt3t8XEK?p=preview var app = angular.module('plunker', []); app.service('test', ['$http', '$rootScope', function ($http, $rootScope) { var data = 0; var obj = { "data": 0 }; this.add = function(){ obj.data += 1; console.log('data:', obj); }; this.getData = function() { return obj; }; }]); app.controller('TestController', ['$scope', '$rootScope', '$filter', 'test', function($scope, $rootScope, $filter, test) { //test controller $scope.add = function(){ test.add();

SCSS / SASS to CSS in special folder with PHPstorm 7 file watcher

无人久伴 提交于 2019-12-02 21:26:42
I used PHPstorm 6 and my SCSS-Files were compiled into the CSS-Folder, so I have: css -- main.css img js scss -- main.scss -- _variables.scss ... Hier are my definitions on SCSS File Watcher Everthing worked fine, but yesterday I updated my PHPstorm from version 6 to 7 and now my SCSS compile / file watcher are not working anymore. The File Watcher compile the CSS-File into the SCSS-Folder. But I want it in my CSS-Folder!!! What are your settings in PHPstorm 7 Filewatcher for SCSS Files? here is my data structure, you'll see the file style.css with FileDirName/css/style.css one folder "to high

Is there a smarter alternative to “watch make”?

落爺英雄遲暮 提交于 2019-12-02 18:57:45
I ran into this useful tip that if you're working on files a lot and you want them to build automatically you run: watch make And it re-runs make every couple seconds and things get built. However ... it seems to swallow all the output all the time. I think it could be smarter - perhaps show a stream of output but suppress Nothing to be done for 'all' so that if nothing is built the output doesn't scroll. A few shell script approaches come to mind using a loop and grep ... but perhaps something more elegant is out there? Has anyone seen something? This one-liner should do it: while true; do

Detect file content changes from node.js

烂漫一生 提交于 2019-12-02 13:26:43
问题 I have a simple file watcher build with chokidar require('chokidar').watch('./target.txt', {}).on('all', function(event, path) { console.log(event, path); }).on('ready', function() { console.log('ready'); }); It causes change event every time when I re-save file even without changes. Is there a way to make this fire events only if actual content has been changed? 回答1: You can use the stats parameter delivered on add and change . This will only work for changes on the size of the file, which

by changing a service from 'outside' angular js the watchers stop working

吃可爱长大的小学妹 提交于 2019-12-02 08:04:36
问题 I am doing so: angular.element('body').injector().get("myService").somevar = true And somewhere else I'm grabbing it: $scope.$watch( function () { return myService.somevar; }, function (somevar) { console.log(somevar) }); But the watcher does not trigger, even though if i check the value through the console it has in fact changed 回答1: As already mentioned, you need to use $apply: $apply() is used to execute an expression in angular from outside of the angular framework. (For example from

by changing a service from 'outside' angular js the watchers stop working

老子叫甜甜 提交于 2019-12-02 06:35:42
I am doing so: angular.element('body').injector().get("myService").somevar = true And somewhere else I'm grabbing it: $scope.$watch( function () { return myService.somevar; }, function (somevar) { console.log(somevar) }); But the watcher does not trigger, even though if i check the value through the console it has in fact changed As already mentioned, you need to use $apply : $apply() is used to execute an expression in angular from outside of the angular framework. (For example from browser DOM events, setTimeout, XHR or third party libraries). Because we are calling into the angular

Viewing an object in Locals or Watch window causes excel to crash

青春壹個敷衍的年華 提交于 2019-12-01 20:20:39
问题 In Excel when I'm running some code and put a breakpoint in I can look at the values of things in the locals window. In the locals window, when I try to expand a object for the class I've created Excel Crashes with "Microsoft Office Excel has encountered a problem and needs to close. We are sorry for the inconvinience. This also happens if I try to view the object in the watch window. Any ideas? Or anyone had this before? Thanks, Chris 回答1: Check, check again and recheck your class properties

$watch not working on variable from other controller?

跟風遠走 提交于 2019-12-01 10:40:15
I have one controller which displays a checklist, and stores the selection in an array. My other controller runs an $http.get on the array from the first controller. How do I set a $watch so that whenever the array changes, a new HTTP GET request is sent? My attempt: http://plnkr.co/edit/EaCbnKrBQdEe4Nhppdfa // See plnkr for other controller + FooSelection factory + view function SimpleQueryResCtrl($scope, $http, FooSelection) { $scope.foo_list_selection = FooSelection; $scope.$watch('foo_list_selection', function (newValue, oldValue) { if (newValue !== oldValue) $http.get('/api/' + $scope.foo

Grunt - Watch a file and SFTP when it's changed

泄露秘密 提交于 2019-11-30 20:07:00
I'm trying to automatically upload a .css file, when it's compiled from Sass. This is what I've got in my Gruntfile.js : module.exports = function(grunt) { // Project configuration. grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), watch: { coffee: { files: ['**/*.coffee'], tasks: ['coffee'] }, scripts: { files: ['**/*.scss'], tasks: ['compass'] }, sftp: { files: ['**/*.css'], tasks: ['sftp-deploy'] } }, coffee: { compile: { files: { 'testing.js': 'testing.coffee' } } }, compass: { dist: { options: { config: 'config.rb' } } }, 'sftp-deploy': { build: { auth: { host: 'example.com',

GULP 快速上手教程

孤者浪人 提交于 2019-11-30 17:44:13
GULP gulp是前端开发过程中对代码进行构建的工具她不仅能对网站资源进行优化,而且在开发过程中很多重复的任务能够使用正确的工具自动完成;使用她,我们不仅可以很愉快的编写代码,而且大大提高我们的工作效率。 gulp是基于Nodejs的自动任务运行器,她能自动化地完成 javascript/coffee/sass/less/html/image/css 等文件的的测试、检查、合并、压缩、格式化、浏览器自动刷新、部署文件生成,并监听文件在改动后重复指定的这些步骤。在实现上,她借鉴了Unix操作系统的管道(pipe)思想,前一级的输出,直接变成后一级的输入,使得在操作上非常简单。 gulp 和 grunt 非常类似,但相比于 grunt 的频繁 IO 操作,gulp 的流操作,能更快地更便捷地完成构建工作。 gulp 是基于note.js的首先确保自己已经安装了node.js 选装cnpm npm插件都是在外国的服务器上,因为网络波动影响比较大。所以我们可以去淘宝对我们做了很大的贡献 网址 http://npm.taobao.org #1.安装淘宝的镜像 他的命令是:npm install -g cnpm --registry=https://registry.npm.taobao.org #2.生成项目描述文件 packge.json cnmp init (可以代替 npm init