尝试使用@Page装饰器使用新的深层链接系统.
我想我已经正确设置了所有内容(控制台中没有显示错误),但URL没有出现.这是我的代码
app.module.ts
import { NgModule, ErrorHandler } from '@angular/core';
import { IonicApp, IonicModule, IonicErrorHandler } from 'ionic-angular';
import { MyApp } from './app.component';
import { HomePageModule } from '../pages/home/home.module';
import { JobsPageModule } from '../pages/jobs/jobs.module';
import { BrowserModule } from '@angular/platform-browser';
import { HttpModule } from '@angular/http';
import { SplashScreen } from '@ionic-native/splash-screen';
import { StatusBar } from '@ionic-native/status-bar';
@NgModule({
declarations: [
MyApp
],
imports: [
BrowserModule,
HttpModule,
HomePageModule,
JobsPageModule,
IonicModule.forRoot(MyApp)
],
bootstrap: [IonicApp],
entryComponents: [
MyApp
],
providers: …Run Code Online (Sandbox Code Playgroud) 我用laravel写后端。并尝试从IONIC使用中调用api @angular/http。
在后端服务器中,我已经添加Access-Control-Allow-Origin了中间件和响应。
中间件。
return $next($request)
->header('Access-Control-Allow-Origin', '*')
->header('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE')
->header('Access-Control-Allow-Credentials', true)
->header('Access-Control-Allow-Headers', 'Content-Type')
->header('Vary', 'Origin');
Run Code Online (Sandbox Code Playgroud)
响应。
return response($data, 200)
->withHeaders([
'Content-Type' => 'application/json',
'Access-Control-Allow-Origin' => '*',
'Access-Control-Allow-Methods' => 'GET, POST, PUT, DELETE',
'Access-Control-Allow-Credentials' => true,
'Access-Control-Allow-Headers' => 'Content-Type',
'Vary' => 'Origin',
]);
Run Code Online (Sandbox Code Playgroud)
离子
url: any = 'http://myurl.local/api/';
headers = new Headers(
{
'Accept' : 'application/json',
'Content-Type' : 'application/json',
'Access-Control-Request-Methods' : 'POST'
});
options = new RequestOptions({ headers: this.headers });
login(username, password) {
let …Run Code Online (Sandbox Code Playgroud) 我有一个Ionic/Angular应用程序,我刚刚更新到Ionic 3/Angular 4.我有几个我用于页面的基类...
@Injectable()
export abstract class BasePage {
constructor(
userMessageService: UserMessageService,
logger: Logger,
translate: TranslateService,
derivedClassName: string,
) {
super(userMessageService, logger, translate, derivedClassName);
this.data = new Array<T>();
}
Run Code Online (Sandbox Code Playgroud)
升级后,我现在收到以下警告..
Warning: Can't resolve all parameters for PageBase in D:/dev/myapp/src/pages/page-base.ts: ([object Object], [object Object], [object Object], ?). This will become an error in Angular v5.x
Warning: Can't resolve all parameters for CardPageBase in D:/dev/myapp/src/pages/card-page-base.ts: ([object Object], [object Object], [object Object], ?). This will become an error in Angular v5.x
所以它似乎不喜欢这个string …
我有一个按钮,我为onclick属性定义了doLogout函数,但每次单击该按钮时都会显示以下错误:
Runtime Error function not defined - ReferenceError: function is not defined at HTMLButtonElement.onclick
Run Code Online (Sandbox Code Playgroud)
代码非常简单,我在其他页面中使用它,正确调用该函数.这是我的HTML文件:
<ion-header>
<ion-navbar>
<ion-title>Logout</ion-title>
</ion-navbar>
</ion-header>
<ion-content>
<div padding>
<button ion-button block onclick="doLogout()">Logout</button>
</div>
</ion-content>
Run Code Online (Sandbox Code Playgroud)
这是ts文件:
export class LogoutPage {
constructor(public navCtrl: NavController, public navParams: NavParams,
public api : Api) {
}
doLogout(){
//does something
}
}
Run Code Online (Sandbox Code Playgroud) 我希望在单击按钮时动态更新徽章值.
tabs.html
...
<ion-tab [root]="tab1Root" tabTitle="Product" tabIcon="search"></ion-tab>
<ion-tab [root]="tab2Root" tabTitle="Cart" tabIcon="cart" tabBadge="{{cartCount}}" tabBadgeStyle="danger"></ion-tab>
...
Run Code Online (Sandbox Code Playgroud)
tabs.ts
export class TabsPage {
...
cartCount = 0;
tab1Root = ProductPage;
tab2Root = CartPage;
...
}
Run Code Online (Sandbox Code Playgroud)
product.html
<button ion-button full (click)="updateCart('add', p.id)">Buy Now</button>
Run Code Online (Sandbox Code Playgroud)
product.ts
export class ProductPage {
...
updateCart(action, id) {
let cartCount = 1;
let alert = this.alertCtrl.create({
title: 'Success!',
subTitle: 'You have added 1 product to the cart.',
buttons: ['OK']
});
alert.present();
}
...
}
Run Code Online (Sandbox Code Playgroud)
正如我所说,let cartCount = 1;什么都不做.我已经找到了一个解决方案,但大多数都是针对Ionic 1或AngularJS,它根本没有帮助我.
我似乎遇到了本机插件的问题.
logPath:/Users/philipwilson/workspace/ionic/test2/platforms/ios/cordova/console.log
[21:12:05] console.log: Angular is running in the development mode. Call enableProdMode() to enable the production
mode.
[21:12:05] console.log: Ionic Native: deviceready event fired after 542 ms
[21:12:05] console.warn: Native: tried calling Facebook.browserInit, but the Facebook plugin is not installed.
[21:12:05] console.warn: Install the Facebook plugin: 'ionic plugin add cordova-plugin-facebook4'
Run Code Online (Sandbox Code Playgroud)
我尝试过很多东西.
518 ionic cordova plugin add cordova-plugin-facebook4 --variable APP_ID="99999999999" --variable APP_NAME="test2.com"
565 ionic cordova build ios
578 npm install --save @ionic-native/facebook
593 ionic plugin add cordova-plugin-facebook4
594 ionic cordova …Run Code Online (Sandbox Code Playgroud) 我得到了我认为是iPhone Simulator版本SimulatorApp-829.6 / xCode 9.0中的CORS问题
我构建了带有Cordova的ionic3应用,并可以使用代理在浏览器中运行它。但是当我在SIM卡或手机上运行它时,它不会针对远程http呼叫进行身份验证。
因此,我添加了Cordova调试器并调试到xCode控制台:
这是http错误对象:
{“ _body”:{“ isTrusted”:true},“ status”:0,“ ok”:false,“ statusText”:“”,“ headers”:{},“ type”:3,“ url”:null }
这是我在Ionic应用程序中执行的代码(可在浏览器中使用)
let headers = new Headers();
headers.append('Content-Type', 'application/json');
headers.append('Authorization', 'Basic ' + this.base64Service.encode(id + ':' + pw));
headers.append('Access-Control-Allow-Origin', '*');
return this.http.get('http://myserver.com/api/v1/authenticate', {headers: headers}).map(res => res.json());Run Code Online (Sandbox Code Playgroud)
我真的很困惑,因为有两件事:
1)我已经安装了Cordova白名单插件,并且在针对远程服务器之前取得了成功。不知道发生了什么
2)如果我使用Safari Developer> Simulator并连接到在模拟器中运行的应用程序,则会出现此错误:
Failed to load resource: Origin http://localhost:8080 is not allowed by Access-Control-Allow-Origin.
XMLHttpRequest cannot load http://myserver.com/api/v1/authenticate. Origin http://localhost:8080 is not allowed by Access-Control-Allow-Origin.
Run Code Online (Sandbox Code Playgroud)
如何在Sim或实际设备中获得CORS问题?我认为资源都是基于file://的。另外,为什么Cordova白名单插件不能解决此问题?
提前致谢。在这个上花了很多时间。
使用最新的Ionic CLI时,其制作模块文件.为什么要制作模块文件?另外,如何正确注册此模块?使用模块文件生成标签页或页面有什么好处?例如,在安装选项卡default project(ionic start myApp tabs)时,您不会获得模块文件的标签,也不会使用生成器.
我正在尝试实现ng-repeat的基本示例。我使用的是ionic 3和Angular5。我不知道这是什么问题?帮助我的代码。
manage.html
<ul *ngFor="let room of roomDetail; let i = index">
<li ng-repeat="(key,value) in room">
{{key}} : {{value}}
</li>
</ul>
Run Code Online (Sandbox Code Playgroud)
管理
import {
Component
}
from '@angular/core';
import {
IonicPage, NavController, NavParams
}
from 'ionic-angular';@
IonicPage()@ Component({
selector: 'page-manage',
templateUrl: 'manage.html',
})
export class ManagePage {
public room = {};
public roomDetail = [{
"roomName": "Room-1",
"floorNumber": "2nd Floor",
"buildingName": "Golden Millenium"
}];
constructor(public navCtrl: NavController, public navParams: NavParams) {}
}
Run Code Online (Sandbox Code Playgroud) 我已经对这个错误进行了研究。尝试运行时出现以下错误ionic cordova run ios --livereload:
[cordova] Non-system Ruby in use. This may cause packaging to fail.
[cordova] If you use RVM, please run `rvm use system`.
[cordova] If you use chruby, please run `chruby system`.
[cordova] error: archive not found at path '/Users/yassinezeriouh/Desktop/doday2/platforms/ios/DoDay.xcarchive'
[cordova] ** EXPORT FAILED **
[cordova]
[cordova] CordovaError: Promise rejected with non-error: 'Error code 65 for command: xcodebuild with args: -exportArchive,-archivePath,DoDay.xcarchive,-exportOptionsPlist,/Users/yassinezeriouh/Desktop/doday2/platforms/ios/exportOptions.plist,-exportPath,/Users/yassinezeriouh/Desktop/doday2/platforms/ios/build/device,-allowProvisioningUpdates'
Run Code Online (Sandbox Code Playgroud)
在我的设备上以xcode运行项目可以正常工作,自4个小时以来尝试解决此问题,希望能对您有所帮助。我正在运行iOS 12,使用Xcode 10.1,cordova 8.1.2和ionic 4.40(项目实际上在ionic v3上运行,是在上个月创建的)
我的config.xml(除了android&ios启动/图标部分):
<?xml version='1.0' …Run Code Online (Sandbox Code Playgroud) ionic3 ×10
angular ×7
ionic2 ×4
typescript ×4
cors ×2
javascript ×2
angular5 ×1
cordova ×1
debugging ×1
facebook ×1
html ×1
ios ×1
laravel ×1
laravel-5.4 ×1