marmelab / ng-admin

Add an AngularJS admin GUI to any RESTful API
http://ng-admin-book.marmelab.com/
MIT License
3.95k stars 725 forks source link

[RFR] Angular 1.6 #1297

Closed Kmaschta closed 7 years ago

Kmaschta commented 7 years ago

Fix #1298

TODO

Kmaschta commented 7 years ago

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

image

Phocea commented 7 years ago

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

Kmaschta commented 7 years ago

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

For ref. https://github.com/angular/angular.js/issues/14814

Phocea commented 7 years ago

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

app.config(["$locationProvider", function($locationProvider) {
  $locationProvider.html5Mode(true);
}]);

$locationProvider.hashPrefix('');

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

Kmaschta commented 7 years ago

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.

nikhildev commented 7 years ago

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 commented 7 years ago

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

Kmaschta commented 7 years ago

@jpetitcolas Reviewed