How to set focus on input field?

When a Modal is opened, set focus on a predefined <input> inside this Modal. Define a directive and have it $watch a property/trigger so it knows when to focus the element: Name: <input type=”text” focus-me=”shouldBeOpen”> app.directive(‘focusMe’, [‘$timeout’, ‘$parse’, function ($timeout, $parse) { return { //scope: true, // optionally create a child scope link: function (scope, … Read more

AngularJS : Prevent error $digest already in progress when calling $scope.$apply()

From a recent discussion with the Angular guys on this very topic: For future-proofing reasons, you should not use $$phase When pressed for the “right” way to do it, the answer is currently $timeout(function() { // anything you want can go here and will safely be run on the next digest. }) I recently ran … Read more

angular.service vs angular.factory

angular.service(‘myService’, myServiceFunction); angular.factory(‘myFactory’, myFactoryFunction); I had trouble wrapping my head around this concept until I put it to myself this way: Service: the function that you write will be new-ed: myInjectedService <—- new myServiceFunction() Factory: the function (constructor) that you write will be invoked: myInjectedFactory <— myFactoryFunction() What you do with that is up to … Read more

What is the difference between ‘@’ and ‘=’ in directive scope in AngularJS?

Why do I have to use “{{title}}” with ‘@‘ and “title” with ‘=‘? @ binds a local/directive scope property to the evaluated value of the DOM attribute. If you use title=title1 or title=”title1″, the value of DOM attribute “title” is simply the string title1. If you use title=”{{title}}”, the value of the DOM attribute “title” … Read more

How do I access the $scope variable in browser’s console using AngularJS?

Pick an element in the HTML panel of the developer tools and type this in the console: angular.element($0).scope() In WebKit and Firefox, $0 is a reference to the selected DOM node in the elements tab, so by doing this you get the selected DOM node scope printed out in the console. You can also target … Read more

AngularJS: Service vs provider vs factory

From the AngularJS mailing list I got an amazing thread that explains service vs factory vs provider and their injection usage. Compiling the answers: Services Syntax: module.service( ‘serviceName’, function ); Result: When declaring serviceName as an injectable argument you will be provided with an instance of the function. In other words new FunctionYouPassedToService(). Factories Syntax: … Read more

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