AngularJS not refreshing ngRepeat when updating array

You are modifying the scope outside of angular’s $digest cycle 50% of the time. If there is a callback which is not from angularjs; (posibbly jquery). You need to call $apply to force a $digest cycle. But you cannot call $apply while in $digest cycle because every change you made will be reflected automatically already. … Read more

Can I programmatically apply Angular validation directives inside a custom directive?

One way to do this (i.e. apply existing validators without writing their code again) would be to add the validation directives’ respective attributes and force a re-compile. This would require your directive to have a high-enough priority and also be terminal: true. app.directive(“bkNgValidation”, function($compile){ return { priority: 10000, terminal: true, link: function(scope, element){ element.attr(“ng-required”, “true”); … Read more

In what JS engines, specifically, are toLowerCase & toUpperCase locale-sensitive?

Note: Please, note that I couldn’t test it! As per ECMAScript specification: String.prototype.toLowerCase ( ) […] For the purposes of this operation, the 16-bit code units of the Strings are treated as code points in the Unicode Basic Multilingual Plane. Surrogate code points are directly transferred from S to L without any mapping. The result … Read more

How to destroy an angularjs app?

Using AngularJS 1.4.0, $rootScope.$destroy() is working again (as it was broken in 1.2). Using this permits to switch between several angularJS apps: var appManager = new function () { this.currentAppName; this.currentApp; this.startApp = function (appContainerId, appName) { if (this.currentApp) { this.destroyApp(this.currentApp, this.currentAppName); } var appContainer = document.getElementById(appContainerId); if (appContainer) { this.currentAppName = appName; this.currentApp = … Read more

Getting form controls from FormController

For a direct solution to the question, modify @lombardo’s answer like so; var dirtyFormControls = []; var myForm = $scope.myForm; angular.forEach(myForm, function(value, key) { if (typeof value === ‘object’ && value.hasOwnProperty(‘$modelValue’) && value.$dirty) dirtyFormControls.push(value) }); The array ‘dirtyFormControls’ will then contain the form controls that are dirty. You can also use this trick to show … Read more

W3C validation with AngularJS directives

Strict w3c validation allows any data-* attributes, and any class. Directives can be applied to DOM elements with any of: <tag directive-name> <tag data-directive-name> (*) <tag x-directive-name> <tag directive_name> <tag x_directive_name> <tag data_directive_name> At least the data- one is fully W3C compliant (provided you declare HTML5 doctype). So the following code validates (the attribute name, … Read more