Getting an error when using ng-controller in angularjs ver 1.3.0 [duplicate]

in angular 1.3.0 u have to do like below, Because Global controllers were disabled in 1.3.0-beta. reference <div ng-app=”myApp” ng-controller=”personController”> <script> var app = angular.module(“myApp”,[]); app.controller(‘personController’, function($scope){ $scope.firstName = “David”; $scope.lastName = “Silva”; }) </script> It also said that you can get the older behavior by using below code , but its not recomended <div … Read more

Is there a difference between promise.then.then vs promise.then; promise.then [duplicate]

You have asked about “chaining” vs. “branching”. Assuming that f1 and f2 represent asynchronous operations that return promises, yes there is a significant difference. For option 1: It serializes fn1 and fn2 so that fn2 is not called until after the promise returned by fn1 has been resolved. .catch() applies to an error in either … Read more

angular-ui-router with requirejs, lazy loading of controller

I created working plunker here. Let’s have this index.html: <!DOCTYPE html> <html> <head> <title>my lazy</title> </head> <body ng-app=”app”> <a href=”#/home”>#/home</a> // we have three states – ‘home’ is NOT lazy <a href=”#/”>#/</a> – index // ‘index’ is lazy, with two views <a href=”#/other”>#/other</a> // ‘other’ is lazy with unnamed view <div data-ui-view=”topMenu”></div> <div data-ui-view=””></div> <script … Read more

How to access global js variable in AngularJS directive

I created a working CodePen example demonstrating how to do this the correct way in AngularJS. The Angular $window service should be used to access any global objects since directly accessing window makes testing more difficult. HTML: <section ng-app=”myapp” ng-controller=”MainCtrl”> Value of global variable read by AngularJS: {{variable1}} </section> JavaScript: // global variable outside angular … Read more

angular.js link behaviour – disable deep linking for specific URLs

Adding target=”_self” works in Angular 1.0.1: <a target=”_self” href=”https://stackoverflow.com/auth/facebook”>Sign in with Facebook</a> This feature is documented (https://docs.angularjs.org/guide/$location – search for ‘_self’) If you’re curious, look at the angular source (line 5365 @ v1.0.1). The click hijacking only happens if !elm.attr(‘target’) is true.

Angular: calling controller function inside a directive link function using &

Are you passing the arguments inside {}s? E.g., inside the directive’s link function, you’ll want to call the method like so: scope.someCtrlFn({arg1: someValue}); <div my-directive callback-fn=”ctrlFn(arg1)”></div> app.directive(‘myDirective’, function() { return { scope: { someCtrlFn: ‘&callbackFn’ }, link: function(scope, element, attrs) { scope.someCtrlFn({arg1: 22}); }, } }); function MyCtrl($scope) { $scope.ctrlFn = function(test) { console.log(test); } … Read more

angular js unknown provider

Your code looks good, in fact it works (apart from the calls themselves) when copied & pasted into a sample jsFiddle: http://jsfiddle.net/VGaWD/ Hard to say what is going on without seeing a more complete example but I hope that the above jsFiddle will be helpful. What I’m suspecting is that you are not initializing your … Read more

Implementing loading spinner using httpInterceptor and AngularJS 1.1.5

Thanks to Steve’s hint I was able to implement the loader: Interceptor: .factory(‘httpInterceptor’, function ($q, $rootScope, $log) { var numLoadings = 0; return { request: function (config) { numLoadings++; // Show loader $rootScope.$broadcast(“loader_show”); return config || $q.when(config) }, response: function (response) { if ((–numLoadings) === 0) { // Hide loader $rootScope.$broadcast(“loader_hide”); } return response || … Read more