(js) Improve $scope.$watch
parent
cebd79a66e
commit
77ce13967c
|
@ -56,7 +56,7 @@
|
|||
|
||||
// Wait on user's defaults
|
||||
Preferences.ready().then(function() {
|
||||
$scope.$watch('vm.email', function(email, old) {
|
||||
$scope.$watch(function() { return vm.email; }, function(email, old) {
|
||||
if (email && vm.urlEmail != email) {
|
||||
// Email has changed or doesn't match the current URL (this happens when using md-virtual-repeat)
|
||||
showGenericAvatar();
|
||||
|
@ -70,7 +70,7 @@
|
|||
|
||||
// If sg-src is defined, watch the expression for the URL of a local image
|
||||
if ('sg-src' in $element[0].attributes) {
|
||||
$scope.$watch('vm.src', function(src) {
|
||||
$scope.$watch(function() { return vm.src; }, function(src) {
|
||||
if (src) {
|
||||
// Set image URL and save the associated email address
|
||||
vm.url = src;
|
||||
|
|
|
@ -42,19 +42,20 @@
|
|||
// One-way refresh of the parent window when modifying the message from a popup window.
|
||||
if ($window.opener) {
|
||||
// Update the message flags. The message must be displayed in the parent window.
|
||||
$scope.$watchCollection('viewer.message.flags', function(newTags, oldTags) {
|
||||
$scope.$watchCollection(function() { return vm.message.flags; }, function(newTags, oldTags) {
|
||||
var ctrls;
|
||||
if (newTags || oldTags) {
|
||||
ctrls = $parentControllers();
|
||||
if (ctrls.messageCtrl) {
|
||||
ctrls.messageCtrl.service.$timeout(function() {
|
||||
ctrls.messageCtrl.showFlags = true;
|
||||
ctrls.messageCtrl.message.flags = newTags;
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
// Update the "isflagged" (star icon) of the message. The mailbox must be displayed in the parent window.
|
||||
$scope.$watch('viewer.message.isflagged', function(isflagged, wasflagged) {
|
||||
$scope.$watch(function() { return vm.message.isflagged; }, function(isflagged, wasflagged) {
|
||||
var ctrls = $parentControllers();
|
||||
if (ctrls.mailboxCtrl) {
|
||||
ctrls.mailboxCtrl.service.$timeout(function() {
|
||||
|
@ -67,7 +68,7 @@
|
|||
else {
|
||||
// Flatten new tags when coming from the predefined list of tags (Message.$tags) and
|
||||
// sync tags with server when adding or removing a tag.
|
||||
$scope.$watchCollection('viewer.message.flags', function(_newTags, _oldTags) {
|
||||
$scope.$watchCollection(function() { return vm.message.flags; }, function(_newTags, _oldTags) {
|
||||
var newTags, oldTags, tags;
|
||||
if (_newTags || _oldTags) {
|
||||
newTags = _newTags || [];
|
||||
|
|
|
@ -348,7 +348,7 @@
|
|||
vm.saveProperties = saveProperties;
|
||||
vm.close = close;
|
||||
|
||||
$scope.$watch('properties.calendar.color', function() {
|
||||
$scope.$watch(function() { return vm.calendar.color; }, function() {
|
||||
srcCalendar.color = vm.calendar.color;
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue