Skip to content

Instantly share code, notes, and snippets.

@wellwind
Last active May 10, 2017 13:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wellwind/5b6afaa45b5248b76fe7b3c1e9f4b877 to your computer and use it in GitHub Desktop.
Save wellwind/5b6afaa45b5248b76fe7b3c1e9f4b877 to your computer and use it in GitHub Desktop.
線上Angular讀書會 - Electron & NativeScript開發經驗分享 - NativeScript篇

(先用tns create demo-app --ng看看內容)

建立專案

  1. ng new nativescript-demo
  2. cd nativescript-demo
  3. rm -rf src
  4. tns create src --ng
  5. .gitignore加入
    # NativeScript
    src/node_modules
    src/platforms
    src/app/**/*.js
    
  6. package.json中的scripts加入
    "scripts": {
        "start.ios": "cd src && tns run ios",
        "start.android": "cd src && tns run android",
        "start.ios": "cd src && tns debug ios",
        "start.android": "cd src && tns debug android"
    }
  7. npm run start.iosnpm run start.android
  8. npm run debug.iosnpm run debug.android

加入component

  1. ng g c main
  2. 調整main.component.html
    <StackLayout>
        <Button class="btn btn-primary btn-active" id="button" text="Tap me!" (tap)="onTap($event)"></Button>
    </StackLayout>
  3. @Component中加入moduleId
    @Component({
        moduleId: module.id,
        selector: 'app-main',
        templateUrl: './main.component.html',
        styleUrls: ['./main.component.css']
    })
  4. main.component.ts中加入onTap事件
    onTap($event) {
        console.log($event);
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment