Angular2 + import of ng2 material

I use angular 2 with ng2 material to display radio and flag components, in each component I see that I need to import all the contents of ng2 material and finally use only one component

=> result, it charges my application and makes it slower.

I want to know if I can import only the component that I need, despite the fact that in the documentation for the ng2 material they import all of them.

import {Component} from 'angular2/core';
import {bootstrap} from 'angular2/platform/browser';

import {MATERIAL_DIRECTIVES, MATERIAL_PROVIDERS} from "ng2-material/all"; <<<<<

import {ROUTER_DIRECTIVES} from 'angular2/router';
import { CORE_DIRECTIVES, FORM_DIRECTIVES } from 'angular2/common';

@Component({
    selector: 'radiobox',
    templateUrl: '/radiobox.html',
    styleUrls: ['radiobox.css'],
    directives: [MATERIAL_DIRECTIVES] <<<<<<
+1
source share
2 answers

all.ts . export * from .

:

import {MdAnchor, MdButton} from "./components/button/button";
import {MdCheckbox} from "./components/checkbox/checkbox";
import {MdContent} from "./components/content/content";
import {MdDataTable, MdDataTableHeaderSelectableRow, MdDataTableSelectableRow} from './components/data_table/data_table';
import {MdDialog} from "./components/dialog/dialog";
import {MdDivider} from "./components/divider/divider";
import {MdIcon} from "./components/icon/icon";
import {MdInk} from "./components/ink/ink";
import {
  MdPatternValidator,
  MdMaxLengthValidator,
  MdMinValueValidator,
  MdMaxValueValidator,
  MdNumberRequiredValidator,
  INPUT_VALIDATORS
} from "./components/form/validators";
import {MdMessage, MdMessages} from "./components/form/messages";
import {MdInput, MdInputContainer} from "./components/input/input";
import {MdList, MdListItem} from "./components/list/list";
import {MdProgressLinear} from "./components/progress_linear/progress_linear";
import {MdProgressCircular} from "./components/progress_circular/progress_circular";
import {MdPeekaboo} from "./components/peekaboo/peekaboo";
import {MdRadioButton, MdRadioGroup} from "./components/radio/radio_button";
import {MdRadioDispatcher} from "./components/radio/radio_dispatcher";
import {MdSwitch} from "./components/switcher/switch";
import {MdSubheader} from "./components/subheader/subheader";
import {MdSidenav, MdSidenavContainer} from "./components/sidenav/sidenav";
import {SidenavService} from "./components/sidenav/sidenav_service";
import {MdToolbar} from "./components/toolbar/toolbar";
import {MdTabs, MdTab} from "./components/tabs/tabs";
import {Media} from "./core/util/media";
export * from './components/button/button';

, :

import {
  MdRadioButton, MdRadioGroup
} from "ng2-material/components/radio/radio_button";

. : https://github.com/justindujardin/ng2-material/blob/master/ng2-material/all.ts#L85.

+1

@firasKoubaa, , - import {MdList, MdListItem, MdContent, MdButton} from 'ng2-material/all'; - import {MdButton} from "/ng2-material/components/button/button";

0

All Articles