angularjs-1.6

Possibly unhandled rejection in Angular 1.6

佐手、 提交于 2019-11-27 17:10:37
问题 I have a code with AngularJS: service.doSomething() .then(function(result) { //do something with the result }); In AngularJS 1.5.9 when I have error in the .then() section like: service.doSomething() .then(function(result) { var x = null; var y = x.y; //do something with the result }); I'm getting clear error message: TypeError: Cannot read property 'y' of null But in version 1.6 with the same code I'm getting a different error: Possibly unhandled rejection: {} undefined I know that this is

Best practice for using $rootscope in an Angularjs application?

浪尽此生 提交于 2019-11-27 09:33:50
We have a large Angularjs 1.6 application that has $rootscope scattered throughout the app in over 200 places in filters, services, routes, etc.. so it needs to be refactored, but I'm not sure how to know when to remove it. When is it a best practice to use $rootscope in the application? I've read everything from never, to using it for storing variables, which I assumed was for sharing data between controllers. I've since read that it's better to use factories/services for this use case instead and I also read that one valid use case is to use $rootscope as a global event bus. I didn't really

Angular 1.6.0: “Possibly unhandled rejection” error [duplicate]

陌路散爱 提交于 2019-11-27 07:02:31
This question already has an answer here: Possibly unhandled rejection in Angular 1.6 9 answers We have a pattern for resolving promises in our Angular app that has served us well up until Angular 1.6.0: resource.get().$promise .then(function (response) { // do something with the response }, function (error) { // pass the error the the error service return errorService.handleError(error); }); And here is how we are triggering the error in Karma: resourceMock.get = function () { var deferred = $q.defer(); deferred.reject(error); return { $promise: deferred.promise }; }; Now, with the update to

AngularJS Upgrade (1.5 to 1.6,1.7) Makes directive scope bindings undefined

心不动则不痛 提交于 2019-11-27 02:06:15
I have the following code: angular .module('myApp') .directive('layout', function () { return { restrict: 'E', template: '<div ng-include="layoutCtrl.pageLayout"></div>', controller: 'LayoutController', controllerAs: 'layoutCtrl', bindToController: true, scope: { pageLayout: '=', pageConfiguration: '=', isPreview: '=' } }; }); angular .module('myApp') .controller('LayoutController', LayoutController); function LayoutController($scope, LayoutDTO, LayoutPreviewDTO) { var self = this; self.layoutDTO = LayoutDTO; self.layoutPreviewDTO = LayoutPreviewDTO; var test = $scope; if(self.isPreview) self

AngularJS: How to remove #!/ (bang prefix) from URL?

半世苍凉 提交于 2019-11-26 18:27:12
问题 I already have done $locationProvider.html5Mode(true); but it is not working. Whenever I access http://example.com it goes to http://example.com/#!/ . Code is given here: var myApp = angular.module('myApp', ['ui.router', 'ui.bootstrap']); myApp.config(['$qProvider', function ($qProvider) { $qProvider.errorOnUnhandledRejections(false); }]); myApp.config(function($stateProvider, $urlRouterProvider,$locationProvider) { // For any unmatched url, redirect to EXTRANET home page $urlRouterProvider

AngularJS All slashes in URL changed to %2F

淺唱寂寞╮ 提交于 2019-11-26 16:15:22
I'm having a massive problem with AngularJS routing. Up until recently everything has been fine with the following route: $routeProvider.when('/album/:albumId', { controller: 'albumPageController', templateUrl: 'views/album.html' }); and using the href: <a href="/#/album/{{album.id}}">Link</a> However, now all of the slashes are being encoded into %2F . So when I click the link, or type localhost:8000/#/album/1 into the browser, the URL is changed to: http://localhost:8000/#%2Falbum%2F1 I've tried several things to correct this: Using ng-href instead of href, Not using the first / (ie href="#

Best practice for using $rootscope in an Angularjs application?

时光总嘲笑我的痴心妄想 提交于 2019-11-26 14:46:25
问题 We have a large Angularjs 1.6 application that has $rootscope scattered throughout the app in over 200 places in filters, services, routes, etc.. so it needs to be refactored, but I'm not sure how to know when to remove it. When is it a best practice to use $rootscope in the application? I've read everything from never, to using it for storing variables, which I assumed was for sharing data between controllers. I've since read that it's better to use factories/services for this use case

Error with $http.get in angularJS — Success not a Function [duplicate]

心已入冬 提交于 2019-11-26 14:42:01
This question already has an answer here: Why are AngularJS $http success/error methods deprecated? Removed from v1.6? 2 answers Getting this error: angular.min.js:122 TypeError: $http.get(...).success is not a function at getUserInfo (app.js:7) at new (app.js:12) at Object.invoke (angular.min.js:43) at Q.instance (angular.min.js:93) at p (angular.min.js:68) at g (angular.min.js:60) at g (angular.min.js:61) at g (angular.min.js:61) at angular.min.js:60 at angular.min.js:21 Here is my code: var gitHub = angular.module('gitHub', []); gitHub.controller('mainController', ['$scope', '$http',

Error with $http.get in angularJS — Success not a Function [duplicate]

人走茶凉 提交于 2019-11-26 03:30:33
问题 This question already has answers here : Why are AngularJS $http success/error methods deprecated? Removed from v1.6? (2 answers) Closed 5 months ago . Getting this error: angular.min.js:122 TypeError: $http.get(...).success is not a function at getUserInfo (app.js:7) at new (app.js:12) at Object.invoke (angular.min.js:43) at Q.instance (angular.min.js:93) at p (angular.min.js:68) at g (angular.min.js:60) at g (angular.min.js:61) at g (angular.min.js:61) at angular.min.js:60 at angular.min.js

URL hash-bang (#!/) prefix instead of simple hash (#/) in Angular 1.6

我是研究僧i 提交于 2019-11-26 01:28:40
问题 My URLs on an AngularJS project has changed from localhost:3000/admin#/ to localhost:3000/admin#!/ since the last time I worked on my project... Nothing found on the web, does someone know what is this ? 回答1: It is new from AngularJS 1.6, which added a new hash prefix. Due to aa077e8, the default hash-prefix used for $location hash-bang URLs has changed from the empty string ( '' ) to the bang ( '!' ). If your application does not use HTML5 mode or is being run on browsers that do not support