angularjs-scope

q.all not working for multiple promises

倾然丶 夕夏残阳落幕 提交于 2019-12-07 04:04:14
问题 I have the following q.all calling to resolve two promises. I checked all the posts and tried all other ways of implementation q.all and its the same case var xyzdeffered = $q.defer(); service1.getServiceDetail1($routeParams.id).then(function(promise) { xyzdeffered.resolve(promise); }); var abcdeffered = $q.defer(); service2.getServiceDetail2($routeParams.id).then(function(promise) { abcdeffered.resolve(promise); }); $q.all([ xyzdeffered, abcdeffered ]).then(function(data) { $scope.variable =

AngularJS: Sharing scope between multiple instances of same directive

被刻印的时光 ゝ 提交于 2019-12-07 03:33:26
I'm writing an app that uses the same table with the same data in multiple places. I created a custom directive that allows me to reuse this table. Unfortunately, if I edit the table in one instance, the other instance does not refresh. How do I link these two so that any edits I make to one show up in the other? It sounds like you've mostly figured it out, the hard part is getting your data into a shape where the videos and photos can be shared by the slide show. I recommend doing this in a shared data access object returned by a separate factory in Angular, rather than directly in a scope. I

Set default value inside ngSelect

别来无恙 提交于 2019-12-07 03:25:25
问题 I have a a ngSelect with some options in it. <select data-ng-model="type" data-ng-change="option(type)"> <option data-ng-repeat="type in languages" value="{{type.i18n}}"> {{type.language}} </option> </select> And a Controller angular.module('navigation', []) .controller('NavCtrl',['$scope','$translate', function($scope,$translate){ $scope.option = function(type){ console.log(type) //this display the i18n value of languages $translate.use(type); } $scope.languages = [ { language: "English",

watch factory variable with Angular

我的梦境 提交于 2019-12-07 02:50:34
问题 My single page application has 2 controllers : the first is for my main menu and the second is for the view. They share data with this factory myApp.factory('MenuFactory', function(){ var factory = { Monitor: "doneJob", Control: "", Report: "", Display: "", setMonitor: function(value){ factory.Monitor = value; }, setControl: function(value){ factory.Control = value; }, setReport: function(value){ factory.Report = value; }, setDisplay: function(value){ factory.Display = value; } }; return

filter date returns NaN-NaN-NaN in AngularJS

偶尔善良 提交于 2019-12-07 02:24:20
问题 The filter I created below works on Chrome but not Firefox. I don't understand why. myApp.filter('dateCustom', [ '$filter', function ($filter) { return function (input) { // input => 2014-05-13 15:04:48 if(angular.isDefined(input)){ var d = new Date(input); var time = d.getTime(); return $filter('date')(time,'dd/MM/yyyy'); } } }]); HTML : <span> {{ project.date_created_at | dateCustom }} </span> Chrome Firefox 回答1: Firefox doesn't support a date in that format, you will have to replace the

AngularJS factory property isn't being updated in $scope when not using push()

倾然丶 夕夏残阳落幕 提交于 2019-12-06 22:51:27
问题 I have a factory that is retrieving the data from an external source. As soon as i get the data, i use a second factory to filter it by a certain criteria. The factory property is assigned to scope. Now when i do this in my factory, it doesn't update the scope: factory.foo = [{id:1,name:'foo'}]; // doesn't work therefor also the filterin in a second factory doesn't work factory.foo = Filter.filter(); // doesn't work while this works: factory.foo.push({id:1,name:'foo'}); // works Does anyone

Angular $routeProvider: Why does CRUD new route not work?

徘徊边缘 提交于 2019-12-06 20:29:31
I'm building an Angular app with RESTful CRUD actions. Almost everything is working except for the /users/new route ~ it displays the show view instead of new view specified in $routeProvider. However, '/new' does work. I'm not getting any feedback in the js console. Any ideas or examples I should read? App.config [ '$routeProvider' '$locationProvider' ($routeProvider, $locationProvider, config) -> $routeProvider .when('/', templateUrl: '/partials/home.html' ).when('/users', templateUrl: 'partials/users/index.html' controller: 'UserIndexCtrl' ).when('/users/:id', templateUrl: 'partials/users

when I put ng-controller in div instead of body autocomplete stops working

 ̄綄美尐妖づ 提交于 2019-12-06 20:05:29
I have a textbox with autocomplete capability and after clicking on click me button the text in autocomplete is added as in the table , here is the link that works perfectly fine, var app = angular.module('app', []); app.factory('Service', function() { var typesHash = [ { id :1, name : 'lemon', price : 100, unit : 2.5 }, { id : 2, name : 'meat', price : 200, unit : 3.3 } ]; var localId = 3; availableTags = [ "ActionScript", "AppleScript", "Asp", "BASIC", "C", "C++", "Clojure", "COBOL", "ColdFusion", "Erlang", "Fortran", "Groovy", "Haskell", "Java", "JavaScript", "Lisp", "Perl", "PHP", "Python"

$watchGroup vs $watchCollection?

 ̄綄美尐妖づ 提交于 2019-12-06 17:00:51
问题 There're 2 ways to watch a group of variables in Angular. But what's the difference between them? They both seem to do shallow watches. Are there situations where one is obviously preferable over the other? 回答1: $watchCollection will shallow watch the properties on a single object and notify you if one of them changes. $watchGroup however watches a group of individual watch expressions. They are not functionally equivalent. $watchGroup could be used when you want to watch a multitude of

AngularJS - Pass dynamic object value and call function from Directive

空扰寡人 提交于 2019-12-06 16:44:37
Ctlr.js app.controller('myCtrl', function($scope) { $scope.data = { waterMarkImgPosition: [ {id: 'lowerRight', name: 'Lower Right'}, {id: 'lowerLeft', name: 'Lower Left'}, {id: 'upperRight', name: 'Upper Right'}, {id: 'upperLeft', name: 'Upper left'}, {id: 'center', name: 'Center'} ], selectedPosition: {id: 'upperRight', name: 'UpperRight'} //This sets the default value of the select in the ui }; $scope.watermarkPosition = $scope.data.selectedPosition.id; //pass default position for watermark }); Directive.js app.directive('waterMark', function($timeout) { return { restrict: 'EA', link: