Can you reuse $ scope? $ Watch

I found some code I want to copy / paste and use in two controllers. It watches something. $scope.$watch('thing', function (thing) { // do cool stuff with thing } Instead of copy/paste, I'd like to put it in a service and use the service from both co

How to return several values ​​in

I am trying to return multiple values from $ function. angular.module("MainApp") .directive('isActiveNav', [ '$location', function($location) { return { restrict: 'A', link: function($scope, el, attrs) { $scope.location = $location; $

What is an angular observer?

What are considered "watchers" in Angular? Are watchers themselves the only type of watchers, or are other Angular constructs such as ngModel watchers as well? Or am I missing the big picture? For example, are watchers what enable directives lik

How to use an isolated scope property properly?

How to use an isolated scope property properly? I have a directive, that is called from a page controller, with an attribute item passed to it, e.g. <my-directive item="myItem"></my-directive>, containing an id. The code below will n

Adding values ​​to WatchGroup dynamically in angularjs

I've a button in my angular app that will add an input element to my app dynamically. I want to attach model to this element and put it to watch group for tracking any changes. If user add multiple input elements, I want to add all those models in wa

AngularJS shows the value of the model if the model is not zero

Simple question here. I have this watch: // Watch our model $scope.$watch(function () { // Watch our team name return; }, function (name) { console.log(name); // if we have a name if (name) { // Store our model in the sessio

Angularjs updates the view but not the template

please pay attention this is the opposite of 99% of the related questions on stackoverflow. Mi problem is: I have a dependent select, when the 'Master' select changes, the 'Slave' view gets updated but NOT it's model. WEIRD. Example code: <!DOCTYPE h