Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFR] Angular 1.6 #1297

Merged
merged 11 commits into from
Jan 26, 2017
Merged

[RFR] Angular 1.6 #1297

merged 11 commits into from
Jan 26, 2017

Conversation

Kmaschta
Copy link
Contributor

@Kmaschta Kmaschta commented Jan 17, 2017

Fix #1298

TODO

  • Make it works
  • Make it works on a legacy project
  • Write doc

@Kmaschta Kmaschta force-pushed the angular-1.6 branch 3 times, most recently from dde7f79 to cfe6b8b Compare January 20, 2017 17:00
@Kmaschta Kmaschta changed the title [WIP] Angular 1.6 [RFC] Angular 1.6 Jan 20, 2017
@Kmaschta
Copy link
Contributor Author

Kmaschta commented Jan 20, 2017

@fzaninotto @jpetitcolas @Phocea Ready for comment! It works on ng-admin-demo too.
I still need to check with my legacy project.

image

Copy link
Contributor

@Phocea Phocea left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would also bump angular-mocks version to 1.6.1

@@ -15,13 +15,13 @@
],
"dependencies": {
"admin-config": "~0.12.1",
"angular": "~1.5.11",
"angular": "~1.6.1",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Align angular-mocks version with this one

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

@Phocea
Copy link
Contributor

Phocea commented Jan 23, 2017

Looking good.
Its working on my project too and passed all Selenium tests :)

@Kmaschta
Copy link
Contributor Author

On my legacy project, I have some Function.prototype.bind.apply(...) is not a constructor errors..
I still need to investigate why.

For ref. angular/angular.js#14814

@Phocea
Copy link
Contributor

Phocea commented Jan 23, 2017

For info the only 2 issues I got moving to 1.6.1:

  • $http.success() and .error() have been removed (was deprecated before)
  • App url changed from having # to #!. I have set locationProvider to use HTML5 mode to clean this up or remove the suffix
app.config(["$locationProvider", function($locationProvider) {
  $locationProvider.html5Mode(true);
}]);

$locationProvider.hashPrefix('');

might be worth mentioning in the release notes (its explained here)

@Kmaschta
Copy link
Contributor Author

Ok, it works well on my legacy project!

The error Function.prototype.bind.apply(...) is not a constructor was related to controllers and services that was defined with a arrow functions (() => {}) and not by real functions (function ()).

You're right, I'll update the doc.

@Kmaschta Kmaschta changed the title [RFC] Angular 1.6 [RFR] Angular 1.6 Jan 24, 2017
@Kmaschta Kmaschta added this to the 1.0 milestone Jan 24, 2017
@nikhildev
Copy link

Hey,

I found this as some of the very few places where there is some help.
I have a component defined as

import angular from 'angular';

import {IacManagerController} from './iac-manager.controller';

const IacManager = angular.module('app.automation.iac-manager', [])
.controller('IacManagerController', IacManagerController)
.component('automationIacManager', {
  controller: 'IacManagerController as iacManager',
  template: require('./iac-manager.html'),
  bindings: {
   <All my bindings here...>
  }
});

export default IacManager;

when I'm trying to use this in another module like below

import angular from 'angular';
import * as uiRouter from 'angular-ui-router';

import automationRoutes from './automation.routes';
import AutomationController from './automation.controller';
import IacManager from './iac-manager';

const Automation = angular.module('app.automation', [
  uiRouter,

  IacManager.name,
])
.controller('AutomationController', AutomationController)
.config(automationRoutes);

export default Automation;

I get the error TypeError: Function.prototype.bind.apply(...) is not a constructor in my console.
I recently converted all my code to ES6 and my controller is defined like below

export default class IacManagerController {
  constructor($scope, $interval) {}
}

This error has been haunting me now. Can't seem to get a hang of it. Any advice?

@Kmaschta
Copy link
Contributor Author

Hi @nikhildev,

This isn't the place for that but as explained on this angular issue, somewhere on your code you define a service, provider or controller with an arrow function () => {} instead of a real function function () or a class.

I don't see anything like that in your comment but I suggest you to search ALL .provider, .service and controller of your codebase and check for arrow function. I struggled too in order to find them all.

If it can't help, ping me on Gitter https://gitter.im/marmelab/ng-admin


To do so you can follow the Angular Migration Guide [from 1.4 to 1.5](https://docs.angularjs.org/guide/migration#migrating-from-1-4-to-1-5) then [from 1.5 to 1.6](https://docs.angularjs.org/guide/migration#migrating-from-1-5-to-1-6).

There are the major changes we've faced:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/There/Here/

@@ -1,5 +1,36 @@
# Upgrade to 1.0

## Angular 1.6
Ng-admin is now ready for Angular 1.6 for security reasons and we strongly recommend you to migrate too.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/Ng/ng/

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/ for security reasons and we strongly recommend you to migrate too./ instead of 1.4, mainly for security reasons. We advise you to update your application too./

## Angular 1.6
Ng-admin is now ready for Angular 1.6 for security reasons and we strongly recommend you to migrate too.

To do so you can follow the Angular Migration Guide [from 1.4 to 1.5](https://docs.angularjs.org/guide/migration#migrating-from-1-4-to-1-5) then [from 1.5 to 1.6](https://docs.angularjs.org/guide/migration#migrating-from-1-5-to-1-6).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/ then/, then/

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/To do so/To do so,/

+$http.then(successFn, errorFn);
```

- No more arrow functions on services and controllers.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/on/in/

$locationProvider.hashPrefix('');
```

- $http no longer support its `.success` and `.error` functions.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/$http/$http/

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/no longer support/doesn't support/

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/functions/functions anymore/

$locationProvider.hashPrefix('');
```

- $http doesn't support its `.success` and `.error` functions.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/$http/$http/


Here are the major changes we've faced:

- The [default hash-prefix changed from `#/` to `#!/`](https://docs.angularjs.org/guide/migration#commit-aa077e8).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/- //

@Kmaschta
Copy link
Contributor Author

@jpetitcolas Reviewed

@jpetitcolas jpetitcolas merged commit ed6a7a4 into master Jan 26, 2017
@jpetitcolas jpetitcolas deleted the angular-1.6 branch January 26, 2017 08:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants