PatrickJS/NG6-starter

Small files structure example using a material modal window

josoroma-zz opened this issue · 1 comments

Hi hackers!

I was wondering if there is a small example of how to use a material modal window to add a item, for example, I am stuck in the following code because I really don't know how to create the files for the HomeAddController:

class HomeController {
  constructor($mdDialog) {
    "ngInject";

    this.mdDialog = $mdDialog;

    this.name = 'home';
  }

  getItems() {
    // ...
  }

  addItem(event) {
    console.log('addItem');

    this.mdDialog.show({
      clickOutsideToClose: true,
      controller: 'HomeAddController',
      controllerAs: '$ctrl',
      focusOnOpen: false,
      targetEvent: event,
      templateUrl: './modal/home.add.html'
    }).then(this.getItems);
  }

  $onInit() {
    //
  }
}

export default HomeController;

Thanks in advance!