<button-large color="green" click="createWorkstation()" busy="disableSave()" busyLabel="Saving...">Save</button-large>
Невозможно наблюдать/наблюдать за областью?
Я не могу наблюдать за изменениями на выходе disableSave()
. Консоль.log(), показанная в моей директиве, никогда не срабатывает при изменении вывода .busy. Что я делаю не так?
directive('buttonLarge', function() {
return {
scope: {
busy: '&',
click: '&'
},
replace: true,
restrict: 'E',
transclude: true,
template: '<button class="buttonL" ng-transclude/>',
link: function (scope, element, attrs) {
//when the button is busy, disable the button
if (angular.isDefined(scope.busy())) {
scope.$watch(scope.busy(), function() {
console.log('watched');
});
attrs.$observe(scope.busy(), function() {
console.log('observed');
});
}
//setup click event - https://groups.google.com/forum/#!topic/angular/-uVE5WJWwLA
if (angular.isDefined(scope.click)) {
element.bind('click', scope.click);
}
}
}
})
Контроллер
$scope.newWorkstationDialog = function (workflowProcess) {
var d = $dialog.
dialog({
resolve: {
workflowProcess: function() {
return workflowProcess;
}
}
}).
open('/partials/admin/'+workflowProcess.entity.slug+'/setup.htm', ['$scope', 'dialog', ..., function ($scope, dialog, ...) {
$scope.saving = false;
/* Create the workstation */
$scope.createWorkstation = function() {
console.log('saving');
$scope.saving = true;
$timeout(function() {
$scope.saving = false;
console.log('stopped saving');
}, 1000);
}
//Should the save button be disabled?
$scope.disableSave = function() {
return $scope.saving;//|| $scope.form.$valid;
}
$scope.cancel = function() {
dialog.close();
}
}]);
}
Я вижу ... хотя они также не работают. – Webnet
любезно поделиться скрипкой или plunker demo pls –
Для жизни меня я никогда не мог получить работу Angular для работы над JSFiddle ... вот моя попытка: http://jsfiddle.net/Webnet/HkXNc/ – Webnet