mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-09 08:09:32 +08:00
feat(demo): tie each ionic component to a standard component
This commit is contained in:
@ -1,27 +1,21 @@
|
|||||||
# Demo
|
# Demo
|
||||||
|
|
||||||
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 1.5.0.
|
The purpose of this application is to provide an Angular CLI application where Ionic Core components can be tested in a simple manner. This application allows the developer to experiment with interactions between Angular and Ionic in an easy and safe manner.
|
||||||
|
|
||||||
## Development server
|
## Getting started
|
||||||
|
|
||||||
Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.
|
From this directory:
|
||||||
|
|
||||||
## Code scaffolding
|
- `npm i`
|
||||||
|
- `npm start` - to serve the application
|
||||||
|
- `npm test` - to run the unit tests
|
||||||
|
- `npm run e2e` - to run the end to end tests
|
||||||
|
|
||||||
Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`.
|
See the `package.json` file for a complete list of script. The above are just the most common.
|
||||||
|
|
||||||
## Build
|
## Running the Angular CLI
|
||||||
|
|
||||||
Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `-prod` flag for a production build.
|
This application installs the Angular CLI locally so you do not need to have it installed globally. You can use `npm` to run any of the `ng` commands. For example:
|
||||||
|
|
||||||
## Running unit tests
|
- `npm run ng build -- --prod` - run a production build
|
||||||
|
- `npm run ng g component my-cool-thing`
|
||||||
Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
|
|
||||||
|
|
||||||
## Running end-to-end tests
|
|
||||||
|
|
||||||
Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/).
|
|
||||||
|
|
||||||
## Further help
|
|
||||||
|
|
||||||
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md).
|
|
||||||
|
|||||||
@ -18,7 +18,7 @@ describe('Demo Inputs Page', () => {
|
|||||||
it('should display the starting text', () => {
|
it('should display the starting text', () => {
|
||||||
page.navigateTo();
|
page.navigateTo();
|
||||||
const el = page.getIonicTextInput();
|
const el = page.getIonicTextInput();
|
||||||
expect(el.getAttribute('value')).toEqual('This is the Ionic Text Input');
|
expect(el.getAttribute('value')).toEqual('This is the Text Input');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should reflect back the entered data', () => {
|
it('should reflect back the entered data', () => {
|
||||||
@ -26,7 +26,7 @@ describe('Demo Inputs Page', () => {
|
|||||||
const el = page.getIonicTextInputEditable();
|
const el = page.getIonicTextInputEditable();
|
||||||
el.clear();
|
el.clear();
|
||||||
el.sendKeys('I am new text');
|
el.sendKeys('I am new text');
|
||||||
expect(page.getIonicTextInputOutputText()).toEqual('I am new text');
|
expect(page.getTextOutput()).toEqual('I am new text');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should trigger validation errors', () => {
|
it('should trigger validation errors', () => {
|
||||||
@ -46,7 +46,7 @@ describe('Demo Inputs Page', () => {
|
|||||||
it('should display the starting text', () => {
|
it('should display the starting text', () => {
|
||||||
page.navigateTo();
|
page.navigateTo();
|
||||||
const el = page.getIonicTextareaInput();
|
const el = page.getIonicTextareaInput();
|
||||||
expect(el.getAttribute('value')).toEqual('This is the Ionic Textarea Input');
|
expect(el.getAttribute('value')).toEqual('This is the Textarea Input');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should reflect back the entered data', () => {
|
it('should reflect back the entered data', () => {
|
||||||
@ -54,7 +54,7 @@ describe('Demo Inputs Page', () => {
|
|||||||
const el = page.getIonicTextareaInputEditable();
|
const el = page.getIonicTextareaInputEditable();
|
||||||
el.clear();
|
el.clear();
|
||||||
el.sendKeys('I am new text');
|
el.sendKeys('I am new text');
|
||||||
expect(page.getIonicTextareaInputOutputText()).toEqual('I am new text');
|
expect(page.getTextareaOutput()).toEqual('I am new text');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should trigger validation errors', () => {
|
it('should trigger validation errors', () => {
|
||||||
@ -81,7 +81,7 @@ describe('Demo Inputs Page', () => {
|
|||||||
page.navigateTo();
|
page.navigateTo();
|
||||||
const el = page.getIonicCheckbox();
|
const el = page.getIonicCheckbox();
|
||||||
el.click();
|
el.click();
|
||||||
expect(page.getIonicCheckboxOutputText()).toEqual('false');
|
expect(page.getCheckboxOutput()).toEqual('false');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -96,7 +96,7 @@ describe('Demo Inputs Page', () => {
|
|||||||
page.navigateTo();
|
page.navigateTo();
|
||||||
const el = page.getIonicToggle();
|
const el = page.getIonicToggle();
|
||||||
el.click();
|
el.click();
|
||||||
expect(page.getIonicToggleOutputText()).toEqual('true');
|
expect(page.getToggleOutput()).toEqual('true');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -9,16 +9,16 @@ export class InputsPage {
|
|||||||
return element(by.id('ionCheckbox'));
|
return element(by.id('ionCheckbox'));
|
||||||
}
|
}
|
||||||
|
|
||||||
getIonicCheckboxOutputText() {
|
getCheckboxOutput() {
|
||||||
return element(by.id('ionCheckboxOutput')).getText();
|
return element(by.id('checkboxOutput')).getText();
|
||||||
}
|
}
|
||||||
|
|
||||||
getIonicToggle() {
|
getIonicToggle() {
|
||||||
return element(by.id('ionToggle'));
|
return element(by.id('ionToggle'));
|
||||||
}
|
}
|
||||||
|
|
||||||
getIonicToggleOutputText() {
|
getToggleOutput() {
|
||||||
return element(by.id('ionToggleOutput')).getText();
|
return element(by.id('toggleOutput')).getText();
|
||||||
}
|
}
|
||||||
|
|
||||||
getTitleText() {
|
getTitleText() {
|
||||||
@ -34,8 +34,8 @@ export class InputsPage {
|
|||||||
return parent.all(by.css('textarea')).first();
|
return parent.all(by.css('textarea')).first();
|
||||||
}
|
}
|
||||||
|
|
||||||
getIonicTextareaInputOutputText() {
|
getTextareaOutput() {
|
||||||
return element(by.id('ionTextareaInputOutput')).getText();
|
return element(by.id('textareaOutput')).getText();
|
||||||
}
|
}
|
||||||
|
|
||||||
getIonicTextInput() {
|
getIonicTextInput() {
|
||||||
@ -47,7 +47,7 @@ export class InputsPage {
|
|||||||
return parent.all(by.css('input')).first();
|
return parent.all(by.css('input')).first();
|
||||||
}
|
}
|
||||||
|
|
||||||
getIonicTextInputOutputText() {
|
getTextOutput() {
|
||||||
return element(by.id('ionTextInputOutput')).getText();
|
return element(by.id('textOutput')).getText();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,81 +6,105 @@
|
|||||||
|
|
||||||
<ion-row>
|
<ion-row>
|
||||||
<ion-col>
|
<ion-col>
|
||||||
<h2>Text Inputs</h2>
|
<h2>Text Input</h2>
|
||||||
</ion-col>
|
</ion-col>
|
||||||
</ion-row>
|
</ion-row>
|
||||||
<ion-row>
|
<ion-row>
|
||||||
<ion-col>
|
<ion-col>
|
||||||
<label for="stdTextInput">Standard Input</label>
|
<label for="stdTextInput">Standard Input</label>
|
||||||
<input id="stdTextInput" name="stdTextInput" [(ngModel)]="stdTextInput" minlength="10"/>
|
<input id="stdTextInput" name="stdTextInput" [(ngModel)]="textValue" minlength="10"/>
|
||||||
</ion-col>
|
</ion-col>
|
||||||
<ion-col>
|
<ion-col>
|
||||||
Standard Text Input:
|
Value:
|
||||||
<span id="stdTextInputOutput">{{stdTextInput}}</span>
|
<span id="textOutput">{{textValue}}</span>
|
||||||
</ion-col>
|
</ion-col>
|
||||||
</ion-row>
|
</ion-row>
|
||||||
<ion-row>
|
<ion-row>
|
||||||
<ion-col>
|
<ion-col>
|
||||||
<ion-item>
|
<ion-item>
|
||||||
<ion-label>Ionic Text Input</ion-label>
|
<ion-label>Ionic Text Input</ion-label>
|
||||||
<ion-input id="ionTextInput" name="ionTextInput" [(ngModel)]="ionTextInput" minlength="10" (ionBlur)="onBlur($event)"></ion-input>
|
<ion-input id="ionTextInput" name="ionTextInput" [(ngModel)]="textValue" minlength="10" (ionBlur)="onBlur($event)"></ion-input>
|
||||||
</ion-item>
|
</ion-item>
|
||||||
</ion-col>
|
</ion-col>
|
||||||
<ion-col>
|
<ion-col>
|
||||||
Ionic Text Input:
|
|
||||||
<span id="ionTextInputOutput">{{ionTextInput}}</span>
|
|
||||||
</ion-col>
|
|
||||||
</ion-row>
|
|
||||||
<ion-row>
|
|
||||||
<ion-col>
|
|
||||||
<ion-item>
|
|
||||||
<ion-label>Ionic Text Area Input</ion-label>
|
|
||||||
<ion-textarea id="ionTextareaInput" name="ionTextareaInput" [(ngModel)]="ionTextareaInput" minlength="10" (ionBlur)="onBlur($event)"></ion-textarea>
|
|
||||||
</ion-item>
|
|
||||||
</ion-col>
|
|
||||||
<ion-col>
|
|
||||||
Ionic Text Input:
|
|
||||||
<span id="ionTextareaInputOutput">{{ionTextareaInput}}</span>
|
|
||||||
</ion-col>
|
</ion-col>
|
||||||
</ion-row>
|
</ion-row>
|
||||||
|
|
||||||
<ion-row>
|
<ion-row>
|
||||||
<ion-col>
|
<ion-col>
|
||||||
<h2>Boolean Inputs</h2>
|
<h2>Textarea Input</h2>
|
||||||
|
</ion-col>
|
||||||
|
</ion-row>
|
||||||
|
<ion-row>
|
||||||
|
<ion-col>
|
||||||
|
<label for="stdTextareaInput">Standard Textarea Input</label>
|
||||||
|
<textarea id="stdTextareaInput" name="stdTextareaInput" [(ngModel)]="textareaValue" minlength="10"></textarea>
|
||||||
|
</ion-col>
|
||||||
|
<ion-col>
|
||||||
|
Value:
|
||||||
|
<span id="textareaOutput">{{textareaValue}}</span>
|
||||||
|
</ion-col>
|
||||||
|
</ion-row>
|
||||||
|
<ion-row>
|
||||||
|
<ion-col>
|
||||||
|
<ion-item>
|
||||||
|
<ion-label>Ionic Textarea Input</ion-label>
|
||||||
|
<ion-textarea id="ionTextareaInput" name="ionTextareaInput" [(ngModel)]="textareaValue" minlength="10" (ionBlur)="onBlur($event)"></ion-textarea>
|
||||||
|
</ion-item>
|
||||||
|
</ion-col>
|
||||||
|
<ion-col>
|
||||||
|
</ion-col>
|
||||||
|
</ion-row>
|
||||||
|
|
||||||
|
<ion-row>
|
||||||
|
<ion-col>
|
||||||
|
<h2>Checkbox</h2>
|
||||||
</ion-col>
|
</ion-col>
|
||||||
</ion-row>
|
</ion-row>
|
||||||
<ion-row>
|
<ion-row>
|
||||||
<ion-col>
|
<ion-col>
|
||||||
<label for="stdCheckbox">Standard Checkbox</label>
|
<label for="stdCheckbox">Standard Checkbox</label>
|
||||||
<input type="checkbox" id="stdCheckbox" name="stdCheckbox" [(ngModel)]="stdCheckbox" (blur)="onBlur($event)" />
|
<input type="checkbox" id="stdCheckbox" name="stdCheckbox" [(ngModel)]="checkboxValue" (blur)="onBlur($event)" />
|
||||||
</ion-col>
|
</ion-col>
|
||||||
<ion-col>
|
<ion-col>
|
||||||
Standard Checkbox:
|
Value:
|
||||||
<span id="stdCheckboxOutput">{{stdCheckbox}}</span>
|
<span id="checkboxOutput">{{checkboxValue}}</span>
|
||||||
</ion-col>
|
</ion-col>
|
||||||
</ion-row>
|
</ion-row>
|
||||||
<ion-row>
|
<ion-row>
|
||||||
<ion-col>
|
<ion-col>
|
||||||
<ion-item>
|
<ion-item>
|
||||||
<ion-label>Ionic Checkbox</ion-label>
|
<ion-label>Ionic Checkbox</ion-label>
|
||||||
<ion-checkbox id="ionCheckbox" name="ionCheckbox" [(ngModel)]="ionCheckbox" (ionBlur)="onBlur($event)"></ion-checkbox>
|
<ion-checkbox id="ionCheckbox" name="ionCheckbox" [(ngModel)]="checkboxValue" (ionBlur)="onBlur($event)"></ion-checkbox>
|
||||||
</ion-item>
|
</ion-item>
|
||||||
</ion-col>
|
</ion-col>
|
||||||
<ion-col>
|
<ion-col>
|
||||||
Ionic Checkbox:
|
</ion-col>
|
||||||
<span id="ionCheckboxOutput">{{ionCheckbox}}</span>
|
</ion-row>
|
||||||
|
|
||||||
|
<ion-row>
|
||||||
|
<ion-col>
|
||||||
|
<h2>Toggle</h2>
|
||||||
|
</ion-col>
|
||||||
|
</ion-row>
|
||||||
|
<ion-row>
|
||||||
|
<ion-col>
|
||||||
|
<label for="stdToggle">Standard Toggle</label>
|
||||||
|
<input type="checkbox" id="stdToggle" name="stdToggle" [(ngModel)]="toggleValue" (blur)="onBlur($event)" />
|
||||||
|
</ion-col>
|
||||||
|
<ion-col>
|
||||||
|
Value:
|
||||||
|
<span id="toggleOutput">{{toggleValue}}</span>
|
||||||
</ion-col>
|
</ion-col>
|
||||||
</ion-row>
|
</ion-row>
|
||||||
<ion-row>
|
<ion-row>
|
||||||
<ion-col>
|
<ion-col>
|
||||||
<ion-item>
|
<ion-item>
|
||||||
<ion-label>Ionic Toggle</ion-label>
|
<ion-label>Ionic Toggle</ion-label>
|
||||||
<ion-toggle id="ionToggle" name="ionToggle" [(ngModel)]="ionToggle" (ionBlur)="onBlur($event)"></ion-toggle>
|
<ion-toggle id="ionToggle" name="ionToggle" [(ngModel)]="toggleValue" (ionBlur)="onBlur($event)"></ion-toggle>
|
||||||
</ion-item>
|
</ion-item>
|
||||||
</ion-col>
|
</ion-col>
|
||||||
<ion-col>
|
<ion-col>
|
||||||
Ionic Toggle:
|
|
||||||
<span id="ionToggleOutput">{{ionToggle}}</span>
|
|
||||||
</ion-col>
|
</ion-col>
|
||||||
</ion-row>
|
</ion-row>
|
||||||
</ion-grid>
|
</ion-grid>
|
||||||
|
|||||||
@ -7,14 +7,11 @@ import { Component, OnInit, ViewEncapsulation } from '@angular/core';
|
|||||||
encapsulation: ViewEncapsulation.None
|
encapsulation: ViewEncapsulation.None
|
||||||
})
|
})
|
||||||
export class InputsTestPageComponent implements OnInit {
|
export class InputsTestPageComponent implements OnInit {
|
||||||
ionTextareaInput = 'This is the Ionic Textarea Input';
|
textareaValue = 'This is the Textarea Input';
|
||||||
ionTextInput = 'This is the Ionic Text Input';
|
textValue = 'This is the Text Input';
|
||||||
stdTextInput = 'This is the HTML Text Input';
|
|
||||||
|
|
||||||
ionCheckbox = true;
|
checkboxValue = true;
|
||||||
stdCheckbox = true;
|
toggleValue = false;
|
||||||
|
|
||||||
ionToggle = false;
|
|
||||||
|
|
||||||
constructor() {}
|
constructor() {}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user