Created
July 3, 2018 07:07
-
-
Save dhavaln/9451ca9eb6b9267ccebc15338fc5e32e to your computer and use it in GitHub Desktop.
ToDo App Component with Analytics custom events
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component } from '@angular/core'; | |
import Amplify, { API, Analytics } from 'aws-amplify'; | |
import aws_exports from '../aws-exports'; | |
@Component({ | |
selector: 'app-root', | |
templateUrl: './app.component.html', | |
styleUrls: ['./app.component.css'] | |
}) | |
export class AppComponent { | |
todos = []; | |
loading = false; | |
ngOnInit(){ | |
Amplify.configure(aws_exports); | |
Analytics.record('app_loaded'); | |
this.loading = true; | |
API.get('sampleCloudApi', '/items', {}).then(data => { | |
this.loading = false; | |
this.todos = data; | |
Analytics.record('todos_loaded'); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment