Angularjs: How to update parent scope in directive without using isolated scope when the attribute is passed in within n
Date : March 29 2020, 07:55 AM
seems to work fine You have attrs.draggableDialog set to "task.show" so when you do scope[attrs.draggableDialog] = false you end up with a element attached to scope that you could access with scope['task.show'] which is different than scope['task']['show'] or scope.task.show To generically set a parent variable to false you need to eval a string containing the assignment. For you it would look like this: scope.$eval(attrs.draggableDialog + ' = false;');
|
angularjs - Watching service properties in a controller scope... changing them from a directive... no update?
Date : March 29 2020, 07:55 AM
Does that help Let's say I have a very simple service with a few properties on it. If I use the service in a controller, put the service's properties on the scope so that they are bound to my view, and update them from the controller, they update in the view. This is the behavior I'd expect. However, if the same service's properties are modified from a directive outside of the controller's scope, the view is not updated (unless something triggers a watch to be updated in the controller's scope?). There is obviously something fundamental that I'm missing here, but search search searching has not led me to the answer. , The problem is that you're calling your service "outside" of angular: element.bind('click', function () {
AuthService.login();
});
element.bind('click', function () {
scope.$apply(function() {
AuthService.login();
});
});
|
AngularJS : directive does not update scope after $http response in parent scope
Date : March 29 2020, 07:55 AM
Does that help Please make sure that data object returning array of student because somtimes you have to use data.data that simple demo should helps you: http://plnkr.co/edit/UMHfzD4oSCv27PnD6Y6v?p=preview $http.get('studen.json').then(function(students) {
$scope.students = students.data; //<-students.data here
},
function(msg) {
console.log(msg)
})
|
AngularJS : How to update controller scope associated to directive scope's object as it changes?
Date : March 29 2020, 07:55 AM
To fix this issue The way you set up 2-way binding for index you could set one up for step as well? And you really do not need index to remove the item, eventhough your directive is isolated it relies on the index from ng-repeat which probably is not a good idea. <plan-step ng-repeat="step in plan.steps" index="$index" step="step"></plan-step>
scope: {
index: '=index',
step:'='
},
return {
template: '<button ng-click="removeStep()">Delete step</button><br><input type="text" ng-model="step.name" />{{step}}<br><br>',
restrict: 'E',
scope: {
step:'='
},
transclude: true,
controller: function($scope, $element, $transclude) {
$scope.removeStep = function() {
$scope.$emit('removeStep', $scope.step);
}
}
$scope.$on('removeStep', function(event, data) {
var steps = $scope.plan.steps;
steps.splice(steps.indexOf(data), 1);
});
return {
template: '<button ng-click="onDelete({step:step})">Delete step</button><br><input type="text" ng-model="step.name" />{{step}}<br><br>',
restrict: 'E',
scope: {
step:'=',
onDelete:'&' //Set up function binding
},
transclude: true
};
<plan-step ng-repeat="step in plan.steps" step="step" on-delete="removeStep(step)"></plan-step>
|
Update angularJs directive scope variable on change parent scope
Date : March 29 2020, 07:55 AM
|