angularjs-scope

AngularJS 1.5+ Components do not support Watchers, what is the work around?

牧云@^-^@ 提交于 2019-12-16 20:16:32
问题 I've been upgrading my custom directives to the new component architecture. I've read that components do not support watchers. Is this correct? If so how do you detect changes on an object? For a basic example I have custom component myBox which has a child component game with a binding on the game . If there is a change game within the game component how do I show an alert message within the myBox? I understand there is rxJS method is it possible to do this purely in angular? My JSFiddle

AngularJS 1.5+ Components do not support Watchers, what is the work around?

天大地大妈咪最大 提交于 2019-12-16 20:16:03
问题 I've been upgrading my custom directives to the new component architecture. I've read that components do not support watchers. Is this correct? If so how do you detect changes on an object? For a basic example I have custom component myBox which has a child component game with a binding on the game . If there is a change game within the game component how do I show an alert message within the myBox? I understand there is rxJS method is it possible to do this purely in angular? My JSFiddle

Angularjs Uncaught Error: [$injector:modulerr] when migrating to V1.3

泪湿孤枕 提交于 2019-12-16 19:55:58
问题 I am learning Angular.js and I am not able to figure out whats wrong with this simple code. It seems to look fine but giving me following error. **Error**: Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.3.14/$injector/modulerr?p0=app&p1=Error%3A%20…gleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.3.14%2Fangular.min.js%3A17%3A381) And before adding ng-app= "app" (I was just keeping it as ng-app ) it was giving me following errors. Why is that? Error: [ng:areq] http://errors

AngularJS global $http state ajax loader

这一生的挚爱 提交于 2019-12-14 03:42:52
问题 I have an AngularJS app, and need an ajax loader for every request done by the $http - is there a simple way to do this. My solution now is to set $rootScope.loading = 1 everytime i call a $http, and on the success set $rootScope.loading = 0.. What is the "best practice" for this? My code now looks like: $rootScope.loading = 1; $http({method : "POST", url:url, data: utils.params(data), headers: {'Content-Type': 'application/x-www-form-urlencoded'}}).success(function() { $rootScope.loading = 0

Referencing the element that is calling a controller function Angularjs ( ng-change / ng-blur / ng-* ? )

限于喜欢 提交于 2019-12-14 03:02:43
问题 The original question asked about how to determine which element called the controllers blurr function, but I didn't clarify that I was not specifically asking about ng-blur , but ng-* ( ng-change , ng-focus , ng-mouseover , ng-*) in general. So, with that in mind: How do I determine which element input is calling the blurr() and/or check() functions? html <body ng-app="test"> <div ng-controller="Cntrlr as cntrlr"> <form name="meta_test"> <input type="text" name='inpt' ng-model="cntrlr.inpt"

Angularjs scope.$apply in directive's on scroll listener

蹲街弑〆低调 提交于 2019-12-13 21:27:06
问题 I am using the following directive to find out if the user has scrolled to the bottom of the page - 150px and set a scope variable which is being listened to and the following page is loaded. It works fine. My concern is that scope.$apply() is being called multiple times. I need to call $apply() for the directive to work but i am not sure if calling it multiple times can cause problems. Any thoughts? Thank you. myMod.directive('scrollDetection', function () { return { restrict: 'AE', link:

how to search and highlight in angular js?

本秂侑毒 提交于 2019-12-13 21:14:43
问题 I have a div in which I have some contend in that .I need to search text from that div and highlight the word (using css class).using next it search next word occurrence and previous occurrence. I am able to make in jquery as example in fiddle http://jsfiddle.net/3MVNj/5/ can you please suggest how I will achieve this in angular js ? plunker http://plnkr.co/edit/V805fEjJAUbAZIuafJcW?p=preview <!DOCTYPE html> <html ng-app="app"> <head> <link data-require="bootstrap-css@3.x" data-semver="3.2.0"

How to avoid using `$parent.$parent.$parent` in nested scopes

二次信任 提交于 2019-12-13 20:08:42
问题 How can I know the Parent controller name in controller chain of Angular? I'm new to Angular so I have one basic question. Suppose, In Angular, I have a controller's chain like below. <div ng-controller="parentController"> ... something in the parent element <div ng-controller="childController"> ... something in the child element </div> </div> Is there any way to write the code in the child element so that I can know the parent controller name in the output (In this case output should be

Accessing $scope properties from inside a service in AngularJS

半世苍凉 提交于 2019-12-13 19:56:24
问题 I am trying to create a constructor function inside an angular service, which I could then use inside of my different angular controllers. The problem is, my object generated from the constructor needs access to one of the properties on my $scope object in order to function correctly. I have the implementation working with the functionality I am after, but it involves passing the $scope object into the constructor function as a parameter. Is there a better way to accomplish this? Are there

Having an Angular $interval running independent of controller

限于喜欢 提交于 2019-12-13 19:18:07
问题 I have different pages on may application which have their own controllers. One of them has an $interval function, let's say a timer. Click on a button will start this interval function, which updates itself every second. What i want to have is, i want to be able to go to any other page in my application (calling different controllers), but i want my interval to continue running until i stop it explicitly from the first controller. A rootScope interval so to speak. How can i do it? EDIT: