angular / components

Component infrastructure and Material Design components for Angular
https://material.angular.io
MIT License
24.23k stars 6.7k forks source link

Angular-Material2 doesn't work with ngUpgrade #1571

Closed DAB0mB closed 7 years ago

DAB0mB commented 7 years ago

Angular-Material2 doesn't work with ngUpgrade

Hello fellows, I've been recently working on a project I'm contributed to, you can find it here. The last part of this tutorial involves migration from Angular1 to Angular2, which requires me to use the UpgradeAdapter provided by ngUpgrade. Unfortunately, once importing the modules provided by Angular-Material2 and bootstrapping the app I receive the following error:

Template parse error: ‘md-input’ is not a known element

For me it seems like a compatibility issue since I'm also contributed to a similar project but purely based on Angular2 and I don't receive the error mentioned above. You can find it here. I tried to look for similar issues but non of them involves the usage of ngUpgrade. Hopefully I didn't do anything wrong, your'e more than welcome to take a look at the project, any help would be appreciated :-)

DAB0mB commented 7 years ago

To prevent some misunderstanding, here is a piece of code of which I used to load Material components:

import { MdButtonModule } from '@angular2-material/button';
import { MdInputModule } from '@angular2-material/input';
import { MdCheckboxModule } from '@angular2-material/checkbox';

// Some lines skipped...

@NgModule({
  declarations: [
    DisplayNamePipe,
    UninvitedPipe,
    PartyDetails,
    PartyUninvited
  ],
  imports: [
    BrowserModule,
    FormsModule,
    MdButtonModule.forRoot(),
    MdInputModule.forRoot(),
    MdCheckboxModule.forRoot()
  ]
})
class AppNg2Module {}

const adapter = new UpgradeAdapter(AppNg2Module);

// Some lines skipped...

function onReady() {
  adapter.bootstrap(document, [SociallyNg1Module.name]);
}
fxck commented 7 years ago

You are using an outdated version of material2, might want to try with the latest version.

https://github.com/angular/material2/blob/master/CHANGELOG.md#breaking-changes

DAB0mB commented 7 years ago

@fxck Unfortunately I encountered a second issue thanks to that update. Apparently there is an unregistered peer dependency of @angular/http so I will keep receiving the error

Can't find module `@angular/http`

Unless manually installed. Any more suggestions?

fxck commented 7 years ago

https://github.com/angular/material2/blob/master/package.json#L30

try clearing your node_modules and doing a fresh npm install

DAB0mB commented 7 years ago

@fxck Nope. Double checked it. If I add it as a peer dependency it is fixed. I opened a separate issue on this topic https://github.com/angular/material2/issues/1574.

jelbourn commented 7 years ago

Fixed in #1579, will be part of the next release.

angular-automatic-lock-bot[bot] commented 4 years ago

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.