service It's in singleton mode

newly added Service class search.service.ts

import {Injectable} from '@angular/core';
export class SearchService {
searchArea: string;
constructor() {
this.searchArea=' guangzhou ';

newly added Service modular service.module.ts

import {NgModule} from '@angular/core';
import {SearchService} from "./search.service"; const services = [
]; @NgModule({
imports: [],
exports: [],
declarations: [],
providers: []
export class ServiceModule {

modify App Root module app.module.ts

import {NgModule} from '@angular/core';
import {ServiceModule} from "./service/service.module"; @NgModule({
declarations: [],
imports: [
bootstrap: [],
entryComponents: [],
providers: []
export class AppModule { }

Among others ts The file uses the Service Methods

import {Component} from '@angular/core';
import {NavController} from "ionic-angular";
import {SearchService} from "../../../app/service/search.service"; @Component({
templateUrl: 'choice.html',
}) export class SearchChoicePage {
constructor(public navCtrl: NavController, private searchService: SearchService) {
} returnArea(name: string) {
this.searchService.searchArea = name;
} }

Original article , Welcome to reprint , Reprint please indicate the source !

Ionic3 newly added Service More articles about

  1. Extended service Modify and add Service Default theme for

    Problem description : Want to be in F:\PHPnow-1.5.6\htdocs\yt\Yourphp\Tpl\       Add a new Service\Default(A)   and Service\new(B) Two themes ...

  2. Kong command ( Two )service

    service Introduce : service It's a statement of a set of And so on . Can be bound route.upstream Upstream and downstream services . And for the route.upstream You can tie ...

  3. Walk into spring And springmvc Actual combat ( Two )

    After chapter one, this article adds jdbc Annotations are used One article is about spingmvc The basic configuration of First, let's look at the annotation ...

  4. be based on Autofac, Castle.DynamicProxy The dynamics of the WCF Solution ( original )

    This solution solves the following problems 3 The main problem : 1. Reduce configuration , In order to avoid every new service You need to modify the configuration file , Including the server side and each client side . 2. Be able to use function overloading , Generic functions , And generic classes . 3. Enable the project to quickly move in w ...

  5. Web Server common settings

    1.Tomcat Browse the catalog Find the file in the installation directory /conf/web.xml,  Find the following configuration section , take parame-value Set to true that will do <init-param>             ...

  6. ionic Dynamic switching during operation API Server address

    ionic Dynamic switching during operation API Server address keywords: ionic,phonegap,cordova, Network system , Dynamic switching , change ,API, Server address ,$resource,localstora ...

  7. Centos Deploy nagios+apache Achieve server monitoring

    1.Nagios Introduce nagios yes   A powerful network monitoring tool , It can effectively monitor windows.linux.unix Host status and router switch network settings , Printer working status, etc , And put the state out of   Now the abnormal service is timely ...

  8. Spring-cloud ( 7、 ... and ) Customize HystrixCommand

    Premise 1. Keep learning Hystrix Before , Sorry to all of you who follow my blog Because the previous project names and the names between services are not very standardized , So I changed these names to facilitate later code management , These codes can be in my github Find , Here's the post ...

  9. Activiti( Two ) springBoot2 Integrate activiti, Integrate activiti Online designer

    Abstract This essay mainly records springBoot2 Integrate activiti Process engine , And embed activiti Online designer for , We can directly edit the process we need through the browser , No need to pass eclipse perhaps IDEA Of actiB ...

Random recommendation

  1. [android] Crack it yourself Flappy Bird( To advertise + Immortality )

    The following is original , Welcome to reprint , Reprint please indicate From everyday blog :  I heard that recently Flappy Bird A fire , but ...

  2. Become JavaGC Experts (1)— Explain profound theories in simple language Java Garbage collection mechanism

    Reprinted from : about Java For developers , Understand garbage collection mechanism (GC) What are the benefits ? First of all, it can satisfy the curiosity of a software engineer , secondly , Deepen understanding GC ...

  3. [OpenJudge 3063] The problem of criminals

    [OpenJudge 3063] The problem of criminals Test description One day , The officer arrested N A suspect , interrogation N On the way to a criminal , As an assistant to the sheriff, you suddenly find that one of them is identified as a criminal K The number one is your brother who once lived and died , You can't just watch him go to jail . ...

  4. jsp Commonly used instructions

    Jsp Contains three compile instructions and seven action instructions . The three compile instructions are :page.include.taglib. The seven action commands are :jsp:forward.jsp:param.jsp:include.jsp:plugi ...

  5. work-7.2

    install ubuntu,jdk ,git,maven,Intellij. To configure GIT when , You need to paste the public key generated locally to the server . Take a seat first , The specific process needs to be supplemented . -------------------------- ...

  6. JavaScript The scope of

    1. Scope The extent to which variables can work , Scope is divided into global scope and local scope Global scope : 1. The outermost function or passing outside the outermost function var Variables defined : 2. window Object's properties and methods have global scope : 3. ...

  7. Java Concurrent : Data transfer and exchange between threads

    from : One . adopt SynchronousQueue Method to achieve data transfer between threads : Threads A With threads B Share a Syn ...

  8. Share a few sets of generation iMac The relevant high-quality products are free of charge mockup And online tools

    I haven't come here for a long time , Today, my sister, I share some high-quality iMac Related design resources , I hope you guys and girls will like it , The most important thing is , All are FREE, There should be applause ~~~ , yeah!! iMac Desktop effects Mockup Just download it ...

  9. Console command , Give Way js Debugging is easier

    One . Command to display information console.log("normal"); // Used to output general information"information"); // For transportation ...

  10. [ turn ] Maniac JSONP

      What is cross domain? ? What is the JSONP?JSONP What technology can achieve ? Is it necessary to use JSONP technology ? Cross domain It is because of JavaScript Restriction of homologous strategy , bring Domain name js Can't operate or Domain ...