angularjs-scope

how to implement confirm on exit in angular 4?

大憨熊 提交于 2020-01-07 08:23:46
问题 I want to know how can I implement a confirm-on-exit component so that on page refresh or leaving tab or window or screen I can execute a confirm on exit method, so that if user click OK he will leave the screen and on click on NO he will remain on same screen? Code I am using here is: import { Component, OnInit, Input, Output, HostListener } from '@angular/core'; @Component({ selector: 'confirmonexit', templateUrl: './confirm-on-exit.html' }) export class ConfirmOnExitComponent { @Input()

How to update angular scope

帅比萌擦擦* 提交于 2020-01-07 08:10:26
问题 i want to make some changes in my controller of the data i get from the server. I made an example of these to explain my problem. The recursive method "update" seems not to update the value of the $scope.gdevPiechartArchiveVolume . Could someone tell me why? Is there a way to trigger the update? Thank you! angular.module('socketTestApp') .controller('MainCtrl', function($scope, Socket) { Socket.on('gdevAreachart_archiveVolume_update', function(data_) { selectArchiveData(data_); }); function

Sharing Data between Child Directives

前提是你 提交于 2020-01-07 04:46:10
问题 I have three directives defined: Parent This should share variables between the other two directives - Child One and Child Two. Child One This contains an input field representing a search term. Whenever this changes I use a link function to update the variable stored in the parent controller. In real world use I will then carry out a search based on this term and update the array. But for simplicity in this example, I just want to create a new array with length 1, which I want to be

Sharing Data between Child Directives

扶醉桌前 提交于 2020-01-07 04:46:04
问题 I have three directives defined: Parent This should share variables between the other two directives - Child One and Child Two. Child One This contains an input field representing a search term. Whenever this changes I use a link function to update the variable stored in the parent controller. In real world use I will then carry out a search based on this term and update the array. But for simplicity in this example, I just want to create a new array with length 1, which I want to be

$scope variable not changing in controller when changed using directive

☆樱花仙子☆ 提交于 2020-01-06 23:46:14
问题 I tried in all ways (keeping the scope to false, etc but not able to change my scope in controller),am I missing something. directive: angular.module("ui.materialize.inputfield", []) .directive('inputField', ["$timeout", function ($timeout) { return { transclude: true, scope: {}, link: function (scope, element) { $timeout(function () { Materialize.updateTextFields(); // The "> > [selector]", is to restrict to only those tags that are direct children of the directive element. Otherwise we

How can we use $scope.$apply method in angular like javascript apply method like function.apply(elem)?

雨燕双飞 提交于 2020-01-06 20:08:45
问题 I created a page with dynamic content in pure javascript and angular in similar. I used apply method in javascript to reuse the function assigned to other element. It works perfectly. I am unable to do the same in angular. please see the below plunkers created in JS and Angular. In function move() method, by onclick I animated to move the text to some distance. To see animation Click on all texts in output in both plunkers. In JS plunker To animate the firstChild in onload, in line 38 I used

Angularjs - $scope.$destroy doesn't remove watchers

不羁岁月 提交于 2020-01-06 19:28:09
问题 I am trying to figure out how to create my own "one time binding", for Angularjs <= 1.2. I found this answer, describing how to create your own bindOnce directive. I do see that when using the following directive: app.directive('bindOnce', function() { return { scope: true, link: function( $scope ) { setTimeout(function() { $scope.$destroy(); }, 0); } } }); Data is binded once. But , I can see that the $$watchers is still on. Take a look at the following JSBin - running the commented watcher

how to have unique scope in ng-repeat in angularjs

天涯浪子 提交于 2020-01-06 17:08:06
问题 Is it possible for me to have multiple array for $scope? i have a list of div with child scopes that is generated from a parent scope in ng-repeat. How can i have the scope variable individually unique? I am generating a list of ng-repeat in another ng-repeat. <div ng-repeat="" ng-init="hide=true" ng-click="hide=!hide"> <div ng-hide="hide" ng-init="childhide=true" ng-click="childhide=!childhide"> <div ng-repeat="" ng-init="childhide" ng-hide="childhide"> <div>{{ variable }}</div> </div> </div

AngularJS How to get data to controller via $rootScope?

浪子不回头ぞ 提交于 2020-01-06 08:42:09
问题 I'm working on an mobile app and I'm having problems with getting data to the controller. What i do is i get the data from a service and that works well (on routing this is '/' or root directory): var listdnModule = angular.module('listdn', []); listdnModule.factory('getActiveDnService', ['$http', function ($http) { return { getActiveDnSvc: function (izvajalecID) { return $http({ method: 'POST', url: 'svc.aspx/getActiveDN', data: "{'izvajalecID':" + "'" + izvajalecID + "'}", cache: true }); }

Passing data between controllers using service and confusion with using [ '$scope' , 'service' , function($scope, service){}]

六眼飞鱼酱① 提交于 2020-01-06 08:32:36
问题 I am badly stuck with this problem of passing data from one controller to other in angularJS. Before my code was: whenever I click on templateController's div, it would trigger setTemplate with the help of ng-click... Now my objective was to send templateController's selected data to ReplyController... After reading forum posts here, i decided to create a service called 'selectionService', so that i can transmit data between 2 controllers... //Defined Service proApp.service('selectionService'