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

Wierd issue: Cannot read propety 'canActivate' of undefined #135

Closed
istrau3 opened this issue Apr 7, 2016 · 3 comments
Closed

Wierd issue: Cannot read propety 'canActivate' of undefined #135

istrau3 opened this issue Apr 7, 2016 · 3 comments

Comments

@istrau3
Copy link

istrau3 commented Apr 7, 2016

I am using the dialog as specified in the docs:

import {inject} from 'aurelia-framework';
import {DialogService} from 'aurelia-dialog';
import {Login} from './login/login';
import {Register} from './register/register';

@inject(DialogService)
export class LoginRegisterDropdown {
    constructor(dialogService) {
        this.dialogService = dialogService;
    }

    login() {
        this.dialogService.open({ viewModel: Login});
    }

    register() {
        this.dialogService.open({ viewModel: Register});
    }
}

Somehow I am getting thrown the error in the description...

I dug into the code a little.
I believe this error is being caused by the code below:

_getViewModel(instruction) {
    if (typeof instruction.viewModel === 'function') {
      instruction.viewModel = Origin.get(instruction.viewModel).moduleId;
    }

    if (typeof instruction.viewModel === 'string') {
      return this.compositionEngine.ensureViewModel(instruction);
    }

    return Promise.resolve(instruction);
  }

basically Origin.get(instruction.viewModel).moduleId is returning undefined.
'./register/register' is definitely the correct relative path...

Thanks in advance.

@istrau3
Copy link
Author

istrau3 commented Apr 7, 2016

I solved this by passing in the absolute path (note: the relative path does not work) to the view-model instead of the class/constructor function itself, like so:

 this.dialogService.open({ viewModel: 'app/nav-bar/login-register-dropdown/register/register'});

Note: I am using webpack, perhaps that is relevant.

@plwalters
Copy link
Contributor

Tracking over in loader-webpack

@lajuffermans
Copy link

Not sure if this is the right place but I'm experiencing similar issues with a non-webpack (aurelia-cli) setup and aurelia-dialog 1.0.0-beta.3.0.1

@istrau3 solution of using the absolute path "solved" it

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

No branches or pull requests

3 participants