orderBy array item value in Angular ng-repeat

Since 1.3.0-rc.5 Since AngularJS 1.3.0-rc.5, the orderBy filter (see the documentation) will automatically sort the array using its items if no additional parameters are provided. <li ng-repeat=”item in items | orderBy”>{{item}}</li> JS Bin Before 1.3.0-rc.5 The orderBy filter (see the historical documentation) can also take a function as second parameter, whose return value will be … Read more

AngularJS access service from different module

A Module is a collection of configuration and run blocks which get applied to the application during the bootstrap process. Modules can list other modules as their dependencies. Depending on a module implies that required module needs to be loaded before the requiring module is loaded. var myModule = angular.module(‘myModule’, [‘module1′,’module2’]); When you injected your … Read more

Subscribe to Property Change in AngularJS

The scope object in AngularJS has a special method called $watch for ‘watching’ scope properties. It accepts a callback that receives the new and the old value of the model: $scope.$watch(‘modelName’, function(newValue, oldValue){ // Do anything you like here }); The callback is on initialization and each time the model changes. Therefore it may be … Read more

Angular ui-router get asynchronous data with resolve

You need to read the docs for resolve. Resolve functions are injectable, and you can use $stateParams to get the correct value from your routes, like so: resolve: { propertyData: function($stateParams, $q) { // The gapi.client.realestate object should really be wrapped in an // injectable service for testability… var deferred = $q.defer(); gapi.client.realestate.get($stateParams.propertyId).execute(function(r) { deferred.resolve(r); … Read more

AngularJS, ui.router, load template and controller based on user role

Loading template and controller based on user role While technically ui-router templateUrl function does not support injecting services you can use templateProvider to inject service that holds role variable or loads it asynchronously and then use $templateFactory to return HTML content. Consider following example: var app = angular.module(‘app’, [‘ui.router’]); app.service(‘session’, function($timeout, $q){ this.role = null; … Read more

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