How to set the dynamic controller for directives?

Now it is possible with AngularJS. In directive you just add two new property called controller , name property and also isolate scope is exactly needed here. Important to note in directive scope:{}, //isolate scope controller : “@”, // @ symbol name:”controllerName”, // controller names property points to controller. Working Demo for Setting Dynamic controller … Read more

Format input value in Angularjs

Here is working example where we use unshift: angular.module(‘myApp.directives’, []).directive(‘format’, [‘$filter’, function ($filter) { return { require: ‘?ngModel’, link: function (scope, elem, attrs, ctrl) { if (!ctrl) return; ctrl.$formatters.unshift(function (a) { return $filter(attrs.format)(ctrl.$modelValue) }); ctrl.$parsers.unshift(function (viewValue) { var plainNumber = viewValue.replace(/[^\d|\-+|\.+]/g, ”); elem.val($filter(attrs.format)(plainNumber)); return plainNumber; }); } }; }]); The HTML seems: <input type=”text” ng-model=”test” … Read more

Changing html5’s source “src” attribute takes no effect wtih angularjs

Here is a couple of angular approaches : 1) Use ng-src= instead of src= The angular docs explain why this works : http://docs.angularjs.org/api/ng.directive:ngSrc During compilation stage, angular will expand the element to include the correct src= attribute. This will change the src attrib of the HTML5 audio element, but unfortunately that is NOT enough to … Read more

AngularJS : How to use one resolve for all the routes of my application

For completeness, here is the whole solution, using angular instead of underscore, with a chainable ‘when’. Nothing new in this code, just combined a bunch of the answers above. var originalWhen = $routeProvider.when; $routeProvider.when = function(path, route) { route.resolve || (route.resolve = {}); angular.extend(route.resolve, { CurrentUser : function(User) { return User.current(); } }); return originalWhen.call($routeProvider, … Read more

Angular.js ng-switch-when not working with dynamic data?

From the docs — Be aware that the attribute values to match against cannot be expressions. They are interpreted as literal string values to match against. For example, ng-switch-when=”someVal” will match against the string “someVal” not against the value of the expression $scope.someVal. So in other words, ng-switch is for hardcoding conditions in your templates. … Read more

How do I fix my generator-angular project so that grunt test works?

I seem to have fixed my problem, for anyone with a similar problem: Within my karma.conf.js I added the following: plugins: [ ‘karma-chrome-launcher’, ‘karma-jasmine’ ], At first I added ‘karma-jasmine’ but was then met with “Can not load “Chrome”, it is not registered!” This was solved by adding ‘karma-chrome-launcher’ as a plug-in Not sure if … Read more

How to apply delay on AngularJS

Just inject $timeout in your controller and use this. $timeout(function() { $scope.displayErrorMsg = false;}, 2000); Also you can use $digest or $apply as below setTimeout(function() { $scope.displayErrorMsg = false; $scope.$digest(); }, 2000); setTimeout(function () { $scope.$apply(function(){ $scope.displayErrorMsg = false; }); }, 2000); Check here how these works, http://www.sitepoint.com/understanding-angulars-apply-digest/

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