angularjs-1.6

Angular Hash versus Hashbang

我的梦境 提交于 2019-12-13 13:27:40
问题 Why does Angular sometimes use a hash in the URL and other times use a hashbang? I've started writing two Angular apps from scratch. Neither are using HTML5 mode. Both have the same default route. However, the default URLs display differently. I've been seeing this random behaviour for at least a year... long before angular-route v1.6. Also, I've always used angular-ui-router. The default route: configRoutes.$inject = ['$urlRouterProvider']; function configRoutes ($urlRouterProvider) {

AngularJS version 1.6 change from `.success` method to `.then` method

ぐ巨炮叔叔 提交于 2019-12-12 14:22:49
问题 actually am following a spring tutorial .. coming to Angularjs he is using .succes var app=angular.module("MyApp",[]); .controller("MyController",function($scope,$http){ $scope.pageProduits=null; $http.get("http://localhost:8080/chercherProduits?mc") .success(function(data){ $scope.pageProduits=data; }) .error(function(err){ console.log(err); }); }); now my problem is that success is not working and after searshing i descovered that The .success and .error methods are deprecated and have been

Do not cache or read cache | AngularJS 1.6 | Bootstrap 3.3

好久不见. 提交于 2019-12-12 02:17:17
问题 I have a modal Bootstrap, inside a call is made $http with Angular. But only when loading the page goes to the server and retrieves the data, the question is: Is it possible to make the call to "http" every time the Bootstrap Modal is opened? var helloApp = angular.module('helloApp',[]); helloApp.controller("CompanyCtrl",['$scope',function($scope){ $scope.numbers = [1,2,3,4,5,6,7,8,9]; $scope.tableTitle = "SEMESTRE "; $scope.checked1 = false; //DELETE $scope.number = 7; $scope.getNumber =

Unable to test a rejected promise after migrating to Angular 1.6.3

冷暖自知 提交于 2019-12-11 06:48:30
问题 I have recently updated my application from Angular 1.5 to 1.6.3 and started getting Jasmine unit test failures (with PhantomJS) around promise based code I have written: Possibly unhandled rejection: undefined thrown Reading around I see that the accepted solution is to chain .then() with .catch() blocks to handle the rejections gracefully. I have done this for one of my source files that I am testing to prove this gets past the error which it does. However, it has now uncovered a further

Pass Directive Isolate Scope Bindings to its Controller `this` Context (AngularJS V1.6)

不羁的心 提交于 2019-12-11 05:10:08
问题 How to pass directive parameter to its controller? I use directive: <directive value="ctrl.item"></directive> .directive('directive', [ function () { return { restrict: 'AE', scope: { value: '=value' }, templateUrl: 'item.html', controller: 'Item as item' }; }]) I want to read value inside a directive's controller: .controller('Item', [function Item () { console.log(this.value); }]) Is it possible to do using this ? 回答1: Set the bindToController property to true .directive('directive', [

How to define an error callback in AngularJS?

青春壹個敷衍的年華 提交于 2019-12-10 18:14:25
问题 In my Controller : function login(credentials) { AuthService .login(credentials) .then(successCallback, errorCallback); //same issue with .then(successCallback).catch(errorCallback); } function successCallback() { // do something after success } function errorCallback(data) { // do something after error } and in my AuthService : authService.login = function (credentials) { return $http .post(ENV.apiEndpoint + 'api/v1/login_check', credentials) .then( function (result) { Session.create(result

Upgrade AngularJs 1.5 to 1.6 - which exact bindings are affected by change in $compile reg controller instances?

半城伤御伤魂 提交于 2019-12-10 04:46:31
问题 Documentation for a change in $compile when upgrading from AngularJs 1.5 to 1.6 states: pre-assigning bindings on component/directive controller instances is disabled by default, which means that they will no longer be available inside the constructors. — AngularJS Developer Guide - Migrating to V1.6 - $compile The upgrade example in the documentation is as follows (shortened): Before .component('myComponent', { bindings: {value: '<'}, controller: function() { //... } }) After .component(

angular-ui-router 1.0.x: event.preventDefault & event.defaultPrevented alternative

荒凉一梦 提交于 2019-12-08 21:00:47
问题 I just replaced the $stateChangeStart with $transitions.onStart $rootScope.$on('$stateChangeStart', function(e, ...){ e.preventDefault(); // other code goes here... }); to $transitions.onStart({}, function(tras){ // need a code equivalent to e.preventDefault // need a code to identify event.defaultPrevented // other code goes here... // get parent states _o.util.getAncestorStates(toState.name, true).reverse() .forEach(function (state) { // certain condition to call event.preventDefault() if

TurboLinks with Angular

不问归期 提交于 2019-12-08 18:34:30
I'm running Angular 1.6 along with TurboLinks 5. For the most part, things are working well. I disabled TurboLinks cache and am manually bootstrapping Angular per some of the suggestions on this post: Using angularjs with turbolinks I have run into one issue though where I have an $interval running within a service. When changing pages via TurboLinks, Angular bootstraps again and the service creates a new interval, but the old one continues to run! Every time a page change event occurs, a new interval is created and they keep piling on top of each other. I tried destroying the angular app when

TurboLinks with Angular

本小妞迷上赌 提交于 2019-12-08 06:26:21
问题 I'm running Angular 1.6 along with TurboLinks 5. For the most part, things are working well. I disabled TurboLinks cache and am manually bootstrapping Angular per some of the suggestions on this post: Using angularjs with turbolinks I have run into one issue though where I have an $interval running within a service. When changing pages via TurboLinks, Angular bootstraps again and the service creates a new interval, but the old one continues to run! Every time a page change event occurs, a new