Skip to content

Demo: Angular 2 + TypeScript  #37

Closed
@leocaseiro

Description

@leocaseiro

Update: Check the solution here

Hi @TheOriginalJosh,

Thanks for this amazing plugin.

I'm trying to setup with Angular, following your instructions, but I'm very confused. It's not really clear what steps I need to follow.

Could you please help me to build an example? That's what I have so far. Thanks:

import {Component, OnInit} from '@angular/core';
import {registerElement, ViewClass} from "nativescript-angular/element-registry";

var SlideContainer = require("nativescript-slides").SlideContainer;
SlideContainer.angular = true; // set the SlideContainer's property of angular to true
registerElement("SlideContainer", () => SlideContainer);

@Component({
    selector: 'slidedemo',
    template: `
    <SlideContainer>
        <Slide class="slide-1" *ngFor="let img of images">
            <Label [text]="img.title"></Label>
            <Image [src]="img.source"></Image>
        </Slide>
    </SlideContainer>
    `
})
export class SlideDemoComponent implements OnInit {

    public images: Array<any> = [];

    ngOnInit() {
        this.images.push(
            {
                title: 'Sports',
                source: 'http://lorempixel.com/400/200/sports/1/'
            }
        );
        this.images.push(
            {
                title: 'Cats',
                source: 'http://lorempixel.com/400/200/cats/1/'
            }
        );
        this.images.push(
            {
                title: 'Food',
                source: 'http://lorempixel.com/400/200/food/1/'
            }
        );
    }


  /** 
   * Then in your angular component in the ngAfterViewInit.
   * you will want to have an instance of your slide container to call the function constructView().
   */
    ngAfterViewInit() {
        SlideContainer.constructView();
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions