$postLink of an angular component/directive running too early

The documentation regarding $postLink() is correct. It’s called after its controller’s element and its children have been linked. This doesn’t mean that you’ll see a directive’s result immediately. Maybe it’s calling $http and inserting the result once it arrives. Maybe it’s registering a watcher which in turns sets the result, as most of Angular’s built-in … Read more

Angular ng-repeat with ng-form, accessing validation in controller

Updated 2015-01-17: As pointed out by Leblanc Meneses in the comments Angular 1.3 now supports interpolation with form, ngForm and input directives. This means that using expressions to name your elements: <div ng-form=”namesForm_{{$index}}” ng-repeat=”name in names”> <input type=”text” name=”input_{{$index}}_0″></input> <!– … –> </div> will work as expected: $scope[‘namesForm_0’] $scope.namesForm_1 // Access nested form elements: $scope.namesForm_1.input_1_0 … Read more

Protractor browser.wait doesn’t wait

It is all about promises (actually every protractor question is about promises). browser.wait() is not a blocking call, it schedules a command to wait for a condition: Schedules a command to wait for a condition to hold, as defined by some user supplied function. If any errors occur while evaluating the wait, they will be … Read more

What is the purpose of square bracket usage in Angular?

It enables AngularJS code to be minified. AngularJS uses parameter names to inject the values to your controller function. In JavaScript minification process, these parameters are renamed to shorter strings. By telling which parameters are injected to the function with a string array, AngularJS can still inject the right values when the parameters are renamed.

How are the attribute prefixes “x-” and “data-” used in AngularJS

The HTML5 spec allows for arbitrary attributes as long as they’re prefixed with data- like so: <div data-myattribute=””></div> Whereas this would be invalid HTML5: <div myattrbute=””></div> For more information on data- attributes, have a look here. As for “x-” attributes, I think you mean “x:” attributes and elements, which are specific to XHTML validation… To … Read more

How to defer routes definition in Angular.js?

Since routes are defined on a provider level, normally new routes can only be defined in the configuration block. The trouble is that in the configuration block all the vital services are still undefined (most notably $http). So, on the surface it looks like w can’t define routes dynamically. Now, it turns out that in … Read more

Differences between returning an object vs a function in a directive definition?

Returning only a function in a directive is just a shorthand for the link function in the full definition. If you are specifying something other than a link function (like templateUrl) then you need to write it the long way: angular.module(“app”). directive(“widgetUno”, [“$http”, function ($http) { return { link: function(scope, element, attrs) { // A … Read more

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