Code Monkey home page Code Monkey logo

imeepos-core's Introduction

imeepos core for angular

import { ICoreModule, IRootPage } from '../../src/app/app';
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { RouterModule } from '@angular/router';
import { LazyModule } from './lazy.module';
import {TestModule} from './test/test.module';
@NgModule({
  imports: [
    BrowserModule,
    RouterModule.forRoot([], {
      useHash: true
    }),
    LazyModule,
    ICoreModule.forRoot()
  ],  
  bootstrap: [IRootPage]
})
export class AppModule { }
  • 懒加载
import { NgModule } from '@angular/core';
import { ICoreModule } from '../../src/app/app';
import { RouterModule } from '@angular/router';
@NgModule({
    imports: [
        RouterModule.forChild([{
            path: 'test',
            loadChildren: 'app/test/test#TestModule'
        }, {
            path: 'test2',
            loadChildren: 'app/test/test2#Test2Module'
        }]),
        ICoreModule.forChild()
    ],
    providers: []
})
export class LazyModule { }
  • router for test
import { Component, NgModule, Injector } from '@angular/core';
import { CorePage, ICoreModule } from '../../../src/app/app';

@Component({
    selector: 'test',
    template: `
        <a (click)="toTest2()">toTest2</a>
    `
})
export class TestPage extends CorePage {
    constructor(
        injector: Injector
    ) {
        super(injector, 'test');
    }

    ngOnInit() {
        // 显示loading
        // this.loading.show();
    }
    ngAfterContentInit() {
        this.log.log('调试状态打印, 非调试状态不打印');
        // 隐藏loading
        setTimeout(() => {
            this.loading.hide();
        }, 1000);
        
    }

    toTest2(){
        this.router.navigate(['test2'])
    }
}

@NgModule({
  imports: [
    ICoreModule.forChild([{
      path: '',
      component: TestPage
    }])
  ],
  declarations: [
    TestPage
  ],
  exports: [TestPage],
})
export class TestModule { }
  • router for test2
import { Component, NgModule, Injector } from '@angular/core';
import { CorePage, ICoreModule } from '../../../src/app/app';

@Component({
    selector: 'test2',
    template: `
        <a (click)="toTest()">toTest</a>
    `
})
export class Test2Page extends CorePage {
    constructor(
        injector: Injector
    ) {
        super(injector, 'test');
    }

    ngOnInit() {
        // 显示loading
        // this.loading.show();
    }
    ngAfterContentInit() {
        this.log.log('调试状态打印, 非调试状态不打印');
        // 隐藏loading
        setTimeout(() => {
            this.loading.hide();
        }, 1000);
    }

    toTest() {
        this.router.navigate(['test'])
    }
}


@NgModule({
    imports: [
        ICoreModule.forChild([{
            path: '',
            component: Test2Page
        }])
    ],
    declarations: [
        Test2Page
    ],
    exports: [Test2Page],
})
export class Test2Module { }
  • 封装常规项目配置,包括首屏加载动画!及日志空页面参数等!

imeepos-core's People

Contributors

meepobrother avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.