HTML5 mobile App Development (3)

Source: Internet
Author: User

HTML5 mobile App Development (3)

Course Content:

Follow the ANGULARJS MVC framework for code refactoring, creating a new DataService service class that uses the SQLite plugin to store local storage of contacts.

Points of knowledge involved:

Angular2 injectable's use of mature module dependency Injection

Referencing a class library

Referencing SQLite plugins and storage,sqlstorage modules

Refactoring code to create a new model

Create a new modules directory, create a new contact.ts, define the type of the field

Create a new DataService

Reference class or plugin pack

Import {storage,sqlstorage} from ' Ionic-angular ';

Import {Contact} from '. /modules/contact ';

Key words

@Injectable ()

That can depend on the injected

Registering a new service

Modify App.ts

Injecting a custom service class

Import {DataService} from './pages/services/dataservice ';

Providers:[dataservice],

Using DataService

Referencing a class library

Import {Contact} from '. /modules/contact ';

Import {DataService} from '. /services/dataservice ';

Injection Services

Private Dataservice:dataservice

Run Test

OK Finish

Next talk about developing custom components (Component) for modular development

HTML5 mobile App Development (3)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.