angular UI router | $stateParams not working

You can’t pass arbitrary parameters between states, you need to have them defined as part of your $stateProvider definition. E.g. $stateProvider .state(‘contacts.detail’, { url: “/contacts/:contactId”, templateUrl: ‘contacts.detail.html’, controller: function ($stateParams) { console.log($stateParams); } }) … The above will output an object with the contactId property defined. If you go to /contacts/42, your $stateParams will be … Read more

Why AngularJS currency filter formats negative numbers with parenthesis?

I know this is an old question, but the accepted answer is only answering why this happens, without a concrete solution to the problem. I think the “most correct way” of doing this, is to use a decorator like so: angular .module(‘app’) .config([‘$provide’, function($provide) { $provide.decorator(‘$locale’, [‘$delegate’, function($delegate) { if($delegate.id == ‘en-us’) { $delegate.NUMBER_FORMATS.PATTERNS[1].negPre=”-\u00A4″; $delegate.NUMBER_FORMATS.PATTERNS[1].negSuf=””; … Read more

How can I automate both E2E and unit tests with Yeoman & AngularJS?

As I mentioned in a comment to your question – PhantomJS saves a lot of hassle. That aside, I believe you can handle everything from within your Gruntfile and just continue to run grunt test to start the whole thing. grunt-karma allows full customization of your karma options with some handy add-ons. From the docs: … Read more

Pass inputs to nested component in Angular 2

I’m not sure if I got it right but here is my implementation ( PLUNKER ) const FIRST_PARTY_OWN_INPUTS = [‘not’, ‘passthrough’]; const FIRST_PARTY_PASSTHROUGH_INPUTS = [‘all’, ‘attrs’, ‘are’, ‘passed’]; const generateAttributes(arr) { return arr.map(att => ‘[‘ + att + ‘] = “‘ + att + ‘”‘).join(‘ ‘); } //——————————————————-////////////////// import {Component} from ‘@angular/core’ @Component({ selector: ‘third-party’, … Read more

Why is $element available/injected in controller?

Quick summary A well written directive that is extendable and/or interacts with other directives will have a controller. That controller needs to access the DOM because it is where that directive’s functionality is defined. Directives are effectively a different way to bind a controller/scope to an element on the page; the preferred way to add … Read more

AngularJS – why is $apply required to properly resolve a $q promise?

In AngularJS the results of resolve() are propagated asynchronously, inside a $digest cycle, not immediately. This means that callbacks registered with then() will only be called (later) when a digest cycle occurs. In your code, nothing is causing Angular to enter a digest cycle, so the then() callback is never called. Calling $apply() is one … Read more

Angular factory returning a promise

$http itself return promise you don’t need to bind it inside the $q this is not a good practice and considered as Anti Pattern. Use:- app.factory(‘settings’, [‘$rootScope’, ‘$http’, ‘$q’, function($rootScope, $http) { return $http.get(‘/api/public/settings/get’) }]); app.controller(‘SomeCtrl’, [‘settings’,$scope, function(settings,$scope) { settings.then(function(result){ $scope.settings=result.data; }); }]); Your way can be done as :- app.factory(‘settings’, [‘$rootScope’, ‘$http’, ‘$q’, function($rootScope, … Read more

Multiple chained deferred functions using q in AngularJS stop returning data

Excerpt taken from the official doc on $q: then(successCallback, errorCallback) – regardless of when the promise was or will be resolved or rejected calls one of the success or error callbacks asynchronously as soon as the result is available. The callbacks are called with a single argument the result or rejection reason. This method returns … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)