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

Defer angularjs watch execution after $digest (raising DOM event)

$timeout is normally what is used to run something after a digest cycle (and after the browser renders). $timeout will cause another digest cycle to be executed after the function is executed. If your trigger does not affect anything Angular, you can set the invokeApply argument to false to avoid running another digest cycle. If … Read more

“Runtime.executionContextCreated has invalid ‘context” error when i run Protractor

2016-10-13: ChromeDriver v2.24 has been released which supports Chrome v52-54. (Thanks @Anton) 2016-08-16: One of the recent updates to the Chrome Dev channel introduced a bug preventing ChromeDriver from properly starting. Having just worked around the same problem, I would suggest backing up your data and reverting to the Beta or Stable release channel of … Read more

how to call function when angular watch cycle or digest cycle is completed

There are couple of ways to do register a callback once a digest is completed. Using $$postDigest: $scope.$$postDigest fires a callback after the current $digest cycle completed. However this runs only once after the next digest cycle. To make it run after each digest cycle run it along with $watch. This is based on the … Read more

How can I hide an element when the page is scrolled?

A basic directive would look like this. One key point is you’ll need to call scope.$apply() since scroll will run outside of the normal digest cycle. app = angular.module(‘myApp’, []); app.directive(“scroll”, function ($window) { return function(scope, element, attrs) { angular.element($window).bind(“scroll”, function() { scope.visible = false; scope.$apply(); }); }; }); I found this jsfiddle which demonstrates … Read more

Angular UI, Bootstrap Navbar Collapse and Javascript

You should replace bootstrap native js properties with ui-bootstrap directives (note the ng-click and collapse): <nav class=”navbar navbar-default” role=”navigation”> <!– Brand and toggle get grouped for better mobile display –> <div class=”navbar-header”> <button type=”button” class=”navbar-toggle” ng-click=”navbarCollapsed = !navbarCollapsed”> <span class=”sr-only”>Toggle navigation</span> <span class=”icon-bar”></span> <span class=”icon-bar”></span> <span class=”icon-bar”></span> </button> <a class=”navbar-brand” href=”#”> <!– your branding here … Read more

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