Angular 2 Dashboard application web api call at initialization

Angular 2 Dashboard application web api call at initialization

By : AVS
Date : November 18 2020, 03:01 PM
I hope this helps you . ngOnInit() was ok to make the api call. I didn't have clear picture of subscribe function . I had to do couple of complex calculation in my typescript file before rendering in the UI. I should be doing this in the subscribe method only. not to assign with a global variable and do a dot operator and expect things to work like charm. I found that until you have listener subscribe does not hold data for your. Meaning if you have large json with nested elements you have to do this.data.innerdata[0].finalvalue[0] in the subscribe method instead pass that to method and do all the fun stuffs.
Pass your information to initData(data) and do all calculation and do the rendering.
code :
export class Recent implements OnInit{
public allFiles_error:Boolean = false;
images = [];

constructor(private _recentService: RecentService) { }

ngOnInit() {
        data => initData(data),
        err => handleError(),
        () => console.log('Completed!'));

    this.allFiles = data;
    console.log("allFiles: ", this.allFiles);
    for(var i = 0; i < this.allFiles.length; i++) {
        thumb: this.allFiles[i].url,
        img: this.allFiles[i].url,
        description: "Image " + (i+1)
    console.log("Images: ", this.images);
    console.log(typeof this.images);

handleError() {
    this.allFiles_error = true;

Share : facebook icon twitter icon
Call dart function in angular controller initialization

Call dart function in angular controller initialization

By : manjunath ac
Date : March 29 2020, 07:55 AM
like below fixes the issue I found out, that it is possible to use window.onload, which is called after my dart function has been exported to JS. Then I use $scope.$apply to change my scope variable.
code :
angular.module("MyApp", []).controller('MyCtrl', function($scope) {
    window.onload = function () {
        $scope.$apply(function () {
            var exchange = {};
            $scope.var = exchange['output'];
Angular 2 call service only on app initialization

Angular 2 call service only on app initialization

By : Doan Van Minh
Date : March 29 2020, 07:55 AM
it should still fix some issue You could use the do operator for this to get the data the first time and reuse them for next calls:
code :
export class XService {
  url = "http://api.example.com"
  constructor(private _http:Http) {


    console.log('made an external request");
    if (this.cachedData) {
      return Observable.of(this.cachedData);
    } else {
      return this._http.get(url)
        .do((data) => {
          this.cachedData = data;
bootstrap(AppComponent, [ XService ]);
How do I create a dashboard layout (or apply a dashboard commercial template) on a project from angular-cli?

How do I create a dashboard layout (or apply a dashboard commercial template) on a project from angular-cli?

By : Miguel_Leal
Date : March 29 2020, 07:55 AM
it fixes the issue Do I need to have a main component (like AppComponent) to show everything inside of it? Or can I have multiple components and its tags defined in the index.html?
You need to think of these parts of your page as components. When you are going to do it in the frameworks/libraries like Angular, React or Vue, all of the HTML generation becomes responsibility of framework. So your HTML will have bare minimum markup and load all the basic stuff; just like you mentioned in the first code sample.
code :
<app-header />
<div class="container">
  <div class="col-md-3">
    <app-sidebar />
  <div class="col-md-9">
    <app-container />
<app-footer />
  selector: 'ng-if-then-else',
  template: `
    <button (click)="show = !show">{{show ? 'hide' : 'show'}}</button>
    <button (click)="switchPrimary()">Switch Primary</button>
    show = {{show}}
    <div *ngIf="show; then thenBlock; else elseBlock">this is ignored</div>
    <ng-template #primaryBlock>Primary text to show</ng-template>
    <ng-template #secondaryBlock>Secondary text to show</ng-template>
    <ng-template #elseBlock>Alternate text while primary text is hidden</ng-template>
class NgIfThenElse implements OnInit {
  thenBlock: TemplateRef<any> = null;
  show: boolean = true;
  primaryBlock: TemplateRef<any> = null;
  secondaryBlock: TemplateRef<any> = null;
  switchPrimary() {
    this.thenBlock = this.thenBlock === this.primaryBlock ? this.secondaryBlock : this.primaryBlock;
  ngOnInit() { this.thenBlock = this.primaryBlock; }
Is there any way to call angular 7 application from angular js application(Single Page Applications)

Is there any way to call angular 7 application from angular js application(Single Page Applications)

By : user3396504
Date : March 29 2020, 07:55 AM
it should still fix some issue You can export your View1, View2 as custom elements (https://medium.com/@tomsu/building-web-components-with-angular-elements-746cd2a38d5b)
code :
  declarations: [View1Component],
  imports: [BrowserModule],
  entryComponents: [View1Component]
export class AppModule {
  constructor(private injector: Injector) {
    const customButton = createCustomElement(View1Component, { injector });
    customElements.define('app-view1', View1Component);

  ngDoBootstrap() {}
<!--AngularJS template-->
        <link rel="stylesheet" href="styles.css">

    <!-- Angular files -->
    <script type="text/javascript" src="runtime.js"></script>
    <script type="text/javascript" src="polyfills.js"></script>
    <script type="text/javascript" src="scripts.js"></script>
    <script type="text/javascript" src="main.js"></script>

    <!-- Using component -->
For Application insights reports - Azure Dashboard Vs PowerBI Dashboard, which one is best?

For Application insights reports - Azure Dashboard Vs PowerBI Dashboard, which one is best?

By : user3636326
Date : March 29 2020, 07:55 AM
this will help Azure Dashboard is specific only for Azure , as per the definition
Related Posts Related Posts :
  • Angular 4 Force navigate with refresh
  • Query dom element's properties Angular 4
  • Angular Material Dialog return value
  • Accessing HTTP Error Response Body from HttpInterceptor in Angular
  • Resolve Adal Token for Http Interceptor
  • Is it possible to change namespace name in @nrwl/nx?
  • Angular 4 Router: Getting redirected inside children's first route
  • Uncaught Error: Template parse error There is not such directive with exportAs
  • How can I use @HostListener('window:beforeunload') to call a method?
  • Is it possible to get the type from a generic, given as parameter
  • Ionic 3 - Preventing browser close
  • How to set the color of an icon in Angular Material?
  • how do i handle POST response
  • constructor being called duplicate in *ngFor due to @ViewChild
  • Angular4 OAuth2 IdentityServer4
  • ERROR TypeError: Cannot read property 'name' of undefined
  • Angular4 http get with URL parameter
  • What is the difference between fakeAsync's tick() and done() in angular2 testing?
  • How to push in service without losing previous data?
  • How to make custom arrow mark in agm-map?
  • Upload File in Angular 4 using FormData works in Local but not on Azure App Service
  • How to automatically deploy a Laravel app with embedded Angular to Heroku
  • Unexpected module 'Ng2SmartTableModule' declared by the module 'AppModule'
  • use angular-cli project with visual studio asp.net empty web app?
  • How to load different templates for the same component?
  • Creating Angular4 'Loading' Screen: ExpressionChangedAfterItHasBeenCheckedError
  • How to pass a array value as color in Angular 4
  • Coerce the HttpResponse into an item of the specified type, complete with custom methods
  • Angular/rxjs: Why don't I have to import toPromise anymore?
  • Angular 2 @Input not works for router outlet
  • Nested Model - Angular 2
  • Supress duplicate error in aot compiler
  • Angular2 ExpressionChangedAfterItHasBeenCheckedError
  • Consuming my promise inside my Angular component
  • Despite error cannot read property length of null, the code works
  • Accessing data returned by Promise.all
  • How to add background image with ngStyle?
  • Property X doesn't exist on type Y[]
  • Ionic Headers Failing to set through http.post
  • Angular 4 routing/state problems
  • ngrx/store:subscribe works fine but async in template gives [object Object]
  • Angular2 - how to mix custom and declared arguments in constructor
  • Implementing Geolocation from @ionic-native/geolocation
  • Angular - Test library before publish
  • AoT Compilation Failed - no such file or directory, lstat 'tsconfig-aot.json'
  • Docker container from Angular4 app : "-p" : executable file not found in $PATH
  • Invalid container name
  • Angular - NgStyle fall back image
  • Angular Observable not updating when I subscribe.
  • Angular mat-checkbox getElementById
  • Angular 4 Injecting route in the APP_INITIALIZER
  • Error: EACCES: Error: EACCES: permission denied, open '/Users/emilio/.ionic/daemon.log' at Error (native)
  • selected value in dropdown list does not work Angular
  • how to smooth scroll down to element on page load angular 4?
  • AngularFire update breaks the app
  • experimentalDecorators Warning on ts lint
  • Dexie - Check if a record exists and initialize it if not present
  • How should I use BehaviorSubject class from a Service in the HTML Template of a Component in Angular 4?
  • How to make ngx-bootstrap datepicker be able to select and display only month and year?
  • What is wrong with this Angular form that makes it reset selected values in the UI unexpectedly?
  • shadow
    Privacy Policy - Terms - Contact Us © voile276.org