有没有办法使用$ ionicHistory.goBack(-2)更改我要返回的状态的$ stateParams?
我正在使用Ionic开发一个小应用程序,但我面临以下问题:
我有几个状态是整个过程的一部分:productInfo,选择和比较.用户选择产品,然后其信息显示在productInfo状态中.所选产品通过$stateParams.
productInfo状态
$stateProvider.state('productInfo', {
url: '/compare/info',
params: {
product: null
},
cache: false,
views: {
'main-screen': {
templateUrl: 'templates/modules/comparator/info.html',
controller: 'CompareInfoCtrl',
controllerAs: 'product'
}
}
})
Run Code Online (Sandbox Code Playgroud)
在productInfo内部,有一个比较按钮,用户进行选择,并选择另一个产品与第一个产品进行比较.
当用户在选择状态下确认他的选择时,应用程序进入最后状态,即比较,显示两个产品的结果.
在最后一个状态(比较)中,如果用户单击其中一个产品,则应用程序必须返回状态1,productInfo,并选择所单击的产品.
我正在使用$ionicHistory.goBack(-2)而不是$state.go('productInfo')避免弄乱我的后退按钮(每个屏幕都有一个默认按钮,它只是调用$ ionicHistory.goBack()).
问题出现了:我无法更改$stateParamsproductInfo状态,因此显示了最后选择的产品.
理想情况就是这样$ionicHistory.goBack(-2, {product: obj}).
我的最后一枪是:
this.$ionicHistory.viewHistory().views[this.$ionicHistory.backView().backViewId].stateParams.id = this.selectedProduct.id;
this.$ionicHistory.goBack(-2);
Run Code Online (Sandbox Code Playgroud)
但这会创造一个新的历史,因此无法按预期工作.
我在离子项目中使用离子标签,但描述没有显示(而是显示点点.. ..)我希望它显示整个文本..有什么解决方案吗?
<ion-card *ngFor="let product of products">
<img [src]="product.imageURL" />
<ion-card-content>
<ion-card-title primary [innerHTML]="product.title"></ion-card-title>
<ion-item class="item-text-wrap">
<ion-item>
<ion-label primary>Description</ion-label>
<ion-label [innerHTML]="product.description"></ion-label>
</ion-item>
</ion-card-content>
</ion-card>
Run Code Online (Sandbox Code Playgroud)
我对Typescript和Ionic 2很新,我试图通过Ionic 2搜索栏过滤json响应.
这是我的代码:
import {Component} from '@angular/core';
import {NavController} from 'ionic-angular';
import {Http} from '@angular/http';
import 'rxjs/add/operator/map';
@Component({
templateUrl: 'build/pages/home/home.html'
})
export class HomePage {
posts: any;
private searchQuery: string = '';
private items: string[];
constructor(private http: Http) {
this.initializeItems();
this.http.get('https://domain.co/open.jsonp').map(res => res.json()).subscribe(data => {
this.posts = data;
console.log(this.posts);
});
}
initializeItems() {
this.items = this.posts;
}
getItems(ev: any) {
// Reset items back to all of the items
this.initializeItems();
// set val to the value of the searchbar …Run Code Online (Sandbox Code Playgroud) 在我尝试使用firebase身份验证服务之后,我得到了一个 uncaught error: a network error (such as timeout, interrupted connection or unreachable host) has occurred
我试图将所有相关域名列入白名单:
<allow-intent href="*.firebaseio.com" />
<allow-intent href="*.firebaseapp.com" />
<allow-intent href="*.google.com" />
<allow-intent href="*.googleapis.com" />
<allow-intent href="*.cloudflare.com" />
<allow-intent href="auth.firebase.com" />
<access origin="*" />
Run Code Online (Sandbox Code Playgroud)
并要求互联网用户许可:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
Run Code Online (Sandbox Code Playgroud)
但仍然 - 尽管代码在网络浏览器上运行完美,它仍然在Android模拟器上显示此错误.
如何以新页面从右侧而不是从底部进入的方式修改navPush?(应该有一些参数,但我没有在离子文档中找到它们
谢谢!
我有这个问题...我的颜色现在是白色的,我的代码是这样的:
<ion-header >
<ion-navbar>
<ion-title>
HELLO
</ion-title>
</ion-navbar>
</ion-header>
Run Code Online (Sandbox Code Playgroud)
使用此选项更改颜色很容易(主要,次要,危险,光线,黑暗)
<ion-header >
<ion-navbar danger>
<ion-title>
HELLO
</ion-title>
</ion-navbar>
</ion-header>
Run Code Online (Sandbox Code Playgroud)
但我的问题是当我想使用自定义颜色时.有人知道如何解决它?提前致谢.
最好的祝福.
我已经开始在Ionic 1中构建简单的Todo应用程序,我发现了Origin头部的问题.(CORS相关)
如果我跑
ionic serve
Run Code Online (Sandbox Code Playgroud)
一切都在浏览器中工作正常,我可以在apache(tomcat)上向我的REST API发出请求.但是当我为Android甚至离子查看器构建我的应用程序时,所有请求都会失败.使用chrome调试器我设法找到问题.
本机应用程序发送标头(仅在Android上测试)
Origin: file://
Run Code Online (Sandbox Code Playgroud)
这导致我的服务器拒绝请求.在我看来,它应该与主机发送正确的Origin标头.下面附有更多细节的屏幕截图.
我该怎么办?
在这里找到相关主题:CORS,Cordova,AngularJs $ http和file://混淆
已经发布在这里,没有运气:https://forum.ionicframework.com/t/native-app-is-sending-header-origin-file-which-causes-problems/62388/1
编辑:发布时出现问题,如果我运行离子启动器(选项卡)模板只$http.post('http://myapp.com/apiv1/device')添加到控制器.
我正在使用Ionic 2.
尝试设置推送通知时,我收到此Typescrpt 错误.我已从教程中复制了此示例代码,因此可以预期它可以正常工作.我一定有错.任何想法请:
Run Code Online (Sandbox Code Playgroud)Unhandled Promise rejection: push.on is not a function ; Zone: angular ; Task: Promise.then ; Value: TypeError: push.on is not a function push.on('registration', function (data) {
打字稿
import { Push } from 'ionic-native';
Run Code Online (Sandbox Code Playgroud)
..
pushNotifications(): void {
var push = Push.init({
android: {
vibrate: true,
sound: true,
senderID: "xxxxxxxxxxxxxxxxxxx"
},
ios: {
alert: "true",
badge: true,
sound: 'false'
},
windows: {}
});
push.on('registration', (data) => {
console.log(data.registrationId);
alert(data.registrationId.toString());
});
push.on('notification', (data) => {
console.log(data);
alert("Hi, …Run Code Online (Sandbox Code Playgroud) 我的离子应用程序中有一个日期时间本地输入框,但我想仅以30分钟的间隔显示分钟,即只有0或30(如9.00或9.30).我读了几步但几分钟都找不到.有没有办法实现它?
我使用Ionic 2,Angular 2和TypeScript构建了一个离子项目来测试框架.我需要在我的项目中包含一个外部库(ntc.js),因为我需要它来命名十六进制颜色.
我知道包含一个Javascript库到TypeScript应该工作,因为JS中的任何工作都适用于TS.我只是不想以错误的方式包含它.
我试图将库添加到www/build/js,但它似乎不起作用,它似乎不是这样做的好方法.我试图寻找方法来做到这一点,但没有发现任何东西(可能是因为Angular 2和Ionic 2仍然是新鲜的).
像 :
import * as ntc from '../../js/ntc';
Run Code Online (Sandbox Code Playgroud)
即使我的图书馆位于正确的地方,似乎也没有效果.TypeScript似乎没有正确读取我的文件,如果它完全读取它.
这样做的好方法是什么?我应该将我的.js文件放在我的项目目录中?
ionic-framework ×10
ionic2 ×6
angular ×5
ionic3 ×4
typescript ×4
angularjs ×3
javascript ×3
android ×1
angularfire ×1
cordova ×1
css ×1
firebase ×1
html5 ×1
sass ×1