Rabu, 13 Maret 2019

elegant way to downgrade all angular components for angular js

My app is supposed to migrate from angularjs to angular.

I'm creating new angular components. Is there an elegant way to automatically import and downgrade component?

Current code:


import { ColorPickerComponent } from './angular-comp/color-picker/color-picker.component';
import {FileSelectComponent } from './angular-comp/file-select/file-select.component';


export default angular
.module('kn-components', myModuleNames)
.directive('colorPicker', downgradeComponent({component: ColorPickerComponent}))
.directive('fileSelect', downgradeComponent({component: FileSelectComponent}))
.name;

Each time I create a component I need to do it, it's quite verbose....

For my angularjs component, for example, I did the following:


const myModuleNames = [];
const loadModules = require.context(".", true, /\.module.js$/);
loadModules.keys().forEach(function (key) {
if(loadModules(key).default)
myModuleNames.push(loadModules(key).default);
});

then:


export default angular
.module('kn-components', myModuleNames)

and all my modules/components are imported



from elegant way to downgrade all angular components for angular js

elegant way to downgrade all angular components for angular js Rating: 4.5 Diposkan Oleh: Admin

1 komentar:

  1. Casino Review (2020) - FilmfileEurope
    Casino Review: 메이저 토토사이트 샤오미 What it Takes to 사다리 사이트 Make a Casino; Bonus Code and More There's a good offer for new players: A winwinbet welcome bonus of up 토토 꽁머니 to €50, and 사설토토 창업 샤오미 a free spins.

    BalasHapus

Popular Posts