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

Avoid wrong click. #64

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open

Avoid wrong click. #64

wants to merge 2 commits into from

Conversation

fanuelson
Copy link

Just an enhancement.

@TwanoO67
Copy link
Owner

TwanoO67 commented Apr 9, 2018

Hello,

How are we supposed to use the AppLoadingComponent ?
Can you provide Example ?

@fabioformosa
Copy link

It seems he encapsuled in an exportable component the black squares that animate during app loading. He got them from bootstrapping-ngx-admin-lte (index.html).
I think it's not a bad idea, but the question is: if app is not initialized yet, how can those squares displayed? It needs to be tried, I've some doubts.

@fanuelson
Copy link
Author

Hello,
@fabioformosa, @TwanoO67
Yes fabio. I did something like that but with a different loading style component.
Here is an example of use.
I use AppLoadingComponent out of the 'AuthComponent'.
I use it in AppComponent:

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  
  isLoading = true;

    constructor(public router: Router) {
        router.events.subscribe((event: RouterEvent) => {
            this.navigationInterceptor(event)
        })
    }

  navigationInterceptor(event: RouterEvent): void {

    if (event instanceof NavigationStart) {
      this.isLoading = true
    }
    if (event instanceof NavigationEnd) {
      this.isLoading = false
    }
    if (event instanceof NavigationCancel) {
      this.isLoading = false
    }
    if (event instanceof NavigationError) {
      this.isLoading = false
    }

  }
}

And here is the AppComponent HTML Example like bootstraping-ngx-admin-lte

<app-route-loading [loading]="isLoading" ></app-route-loading>
<router-outlet></router-outlet>

The component is in the ngx-admin-lte module, separeted from the form of how the users
will use it.
In this example i use the component in AppComponent but can use it in another way.

IMPORTANT: To really see the component in action, its good to create a resolve that makes
any http request that takes some time just to simulate a real scenario.

Observation: My english is bad. So sorry for any mistakes i've made.

@fabioformosa
Copy link

fabioformosa commented Apr 10, 2018

Ok, I understand. It would be great if loading template was customizable through ng-content and the squares were a fallback strategy.
The business logic of hide/show could be embedded in the loading component, couldn't it?

@fanuelson
Copy link
Author

Yeah, It would be great if loading template was customizable through ng-content.

@fabioformosa
The business logic of hide/show could be embedded in the loading component, couldn't it?
i dont think that its a good idea. Its good to left the business logic to the user to create as he desire.

@fabioformosa
Copy link

If you give to the component the name AppLoadingComponent, the only possible logic seems to me a loader that freezes all app (handle the boolean "isLoading", apply a curtain, etc). Instead, I would like to define the style of loader.
If you have a component customizable in style and logic, likely it's would be almost empty and its name should be AComponentShallDoEverythingYouWant.

@fanuelson
Copy link
Author

We can change the name to NgxAdminLteLoading.

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

Successfully merging this pull request may close these issues.

None yet

3 participants