我正在尝试使用TypeScript构建一个ionic2应用程序.
在index.html中,我尝试在cordova.js之前将jquery和google map JS API插入其中:
<!-- Vendor -->
<script src="https://maps.googleapis.com/maps/api/js?key=XXXXX&signed_in=false"></script>
<script src="asset/jquery.min.js"></script>
<!-- cordova.js required for cordova apps -->
<script src="cordova.js"></script>
Run Code Online (Sandbox Code Playgroud)
应用程序内的谷歌地图和jquery正常工作,但只是想知道为什么我运行"ionic serve"命令时显示这些错误消息
TypeScript error: /Users/xxx/client_app/app/pages/step1/step1.ts(15,21): Error TS2304: Cannot find name 'google'.
TypeScript error: /Users/xxx/client_app/app/pages/step1/step1.ts(30,18): Error TS2304: Cannot find name 'google'.
TypeScript error: /Users/xxx/client_app/app/pages/step1/step1.ts(37,24): Error TS2304: Cannot find name 'google'.
TypeScript error: /Users/xxx/client_app/app/pages/step1/step1.ts(39,5): Error TS2304: Cannot find name '$'.
TypeScript error: /Users/xxx/client_app/app/pages/step1/step1.ts(39,42): Error TS2304: Cannot find name '$'.
TypeScript error: /Users/xxx/client_app/app/pages/step1/step1.ts(39,76): Error TS2304: Cannot find name '$'.
Run Code Online (Sandbox Code Playgroud)
以下是我在step1.ts中的代码的一部分:
ngOnInit() { …Run Code Online (Sandbox Code Playgroud) 我正在寻找人行横道,它仍然使得apk超过20 mb ...
是否有任何锻炼使它变小?
我知道这将在带有侧边菜单的离子视图中工作:
<ion-view view-title='<img class="title-image" src="img/my_logo.png" />'>
Run Code Online (Sandbox Code Playgroud)
这将图像放在导航栏中,类标题图像将它放在我想要的位置.到现在为止还挺好.
问题是像这样的东西成为浏览器选项卡上显示的页面标题:
<img class="title-image" ...
Run Code Online (Sandbox Code Playgroud)
- 这不是太酷.
有没有办法将图像放到导航栏上而不将其捏入标题?
我正在尝试在我的离子应用中实施Google身份验证.我在GitHub上找到了这个示例应用程序(点击这里),它使用谷歌登录.
我尝试使用Firebase的迁移指南升级应用程序(单击此处),但我只能在浏览器中使用它,而不是在离子视图或Android模拟器中.
我还在一个单独的应用程序中添加了Google登录,但我只能在浏览器中使用它.
var provider = new firebase.auth.GoogleAuthProvider();
firebase.auth().signInWithPopup(provider).then(function (response) {
// Login successful
}, function(error) {
// Login error
});
Run Code Online (Sandbox Code Playgroud)
任何帮助都会很棒!
一个附带问题,即使我使用新的Firebase控制台,我仍然可以使用Firebase 2.xx吗?我认为Firebase曾经说过我使用新的Firebase控制台,因此需要使用最新的库或其他东西.
authentication android firebase ionic-framework firebase-authentication
我需要创建多个复选框选择框,在框内有分组标签.例
-Appetizer:
- -沙拉
- -等等
-主菜:
- -牛扒
- -等等
-沙漠:
- -冰淇淋
- -等等
这是我的代码:
Run Code Online (Sandbox Code Playgroud)<ion-select [(ngModel)]="food" multiple="true"> <ion-label>Toppings</ion-label> <!-- I want to create group label in here --> <ion-option>Bacon</ion-option> <ion-option>Black Olives</ion-option> <ion-option>Extra Cheese</ion-option> <ion-option>Mushrooms</ion-option> <ion-option>Pepperoni</ion-option> <ion-option>Sausage</ion-option> </ion-select>
如何在离子选择内创建分组标签?谢谢..
我想从我的服务器获取数据,但是我有一个错误.我不知道错误在哪里(coonsole不告诉我)我想从我的服务器获取json,然后用它来显示数据.我使用VersionCtrl但我认为我有语法错误.
我是Angular,Ionic和Javascript的新手.所以..考虑到这一点.
这是list.html
<ion-view view-title="Mis Notas">
<ion-content ng-controller="VersionCtrl">
<ion-list>
<ion-item class="item-remove-animate item-icon-right" href="/#/edit/{{version.success}}" class="item" ng-repeat="version in versiones">
<i class="icon ion-ios-arrow-right"></i>
<h2>{{version.success}}</h2>
<p>{{version.version}}</p>
<ion-option-button class="button-assertive icon-left ion-trash-b" ng-click="remove(version.success)">Eliminar</ion-option-button>
</ion-item>
</ion-list>
<div class="padding">
<a class="button button-block button-positive" href="/#/create">Agregar</a>
</div>
</ion-content>
<div class="bar bar-footer bar-stable">
<a class="button button-positive icon-left ion-compose" href="/#/create">Agregar</a>
</div>
</ion-view>
Run Code Online (Sandbox Code Playgroud)
app.js
(function(){
var app = angular.module('starter', ['ionic'],['starter.notestore'])
app.config(function($stateProvider, $urlRouterProvider){
$stateProvider.state('list',{
url:'/list',
templateUrl:'templates/list.html'
});
$stateProvider.state('edit',{
url:'/edit/:id',
controller:'EditCtrl',
templateUrl:'templates/edit.html'
});
$stateProvider.state('create',{
url:'/create',
controller:'CreateCtrl',
templateUrl:'templates/edit.html'
});
$urlRouterProvider.otherwise('/list');
});
app.controller('ListCtrl', function($scope, NoteStore){
$scope.notas …Run Code Online (Sandbox Code Playgroud) 我目前正处于通过Ionic构建应用程序天气的起始阶段.现在我想实现cordova地理定位,我有错误Unknown provider: $cordovaGeolocationProvider <- $cordovaGeolocation我尝试修复但没有成功,但是这在打开时不断给出错误.出于测试目的,我使用离子服务并在localhost中检查它.
我的代码
(function() {
angular.module('app.weather', ['ionic'])
.factory('Weather', function($q, $http) {
var deferred = $q.defer();
function getCurrentWeather(lat, lng) {
var url = 'https://api.forecast.io/forecast//' + lat + ',' + lng + '?callback=JSON_CALLBACK';
$http.jsonp(url)
.success(deferred.resolve)
.error(deferred.reject);
return deferred.promise;
}
return {
getCurrentWeather: getCurrentWeather
};
})
.controller('WeatherCtrl', function($scope, $cordovaGeolocation, Weather) {
$scope.loading = true;
$scope.toCelsius = function(temperature) {
return ((temperature - 32) / 1.8).toFixed(1);
};
$cordovaGeolocation
.getCurrentPosition({
timeout: 10000,
enableHighAccuracy: false
})
.then(function(position) {
var lat = position.coords.latitude; …Run Code Online (Sandbox Code Playgroud) 我已经完成了一些教程,最后在离子框架中发现了一些关于这一点.....
他们给出了一些使用离子原生的代码,我通过嵌入下面的代码做了同样的事情:
//Display OS name and version (Start)
import { Device } from 'ionic-native';
console.log('Device OS is: ' + Device.device.platform);
console.log('Device OS Version is: ' + Device.device.version);
//Display OS name and version (End)
Run Code Online (Sandbox Code Playgroud)
使用离子服务时,我在控制台中得到了这个:
'Device OS is: undefined'
'Device OS version is: undefined'
Run Code Online (Sandbox Code Playgroud)
然后我猜它不会在浏览器中工作,我尝试在我的手机中构建和运行,但仍然是相同的日志来...
PS:我刚刚开始使用离子
先感谢您 :)
我有带3个按钮的ionic-item-sliding指令.2(A和B)向左滑动时出现,右侧滑动1(按钮C).
我想实现当我真正将项目拖到最右边时触发按钮C下的函数的行为.
ionic2 hompage上的文档以此代码片段为例
ondrag(event, item) {
let percent = event.getSlidingPercent();
if (percent > 0) {
// positive
console.log('right side');
} else {
// negative
console.log('left side');
}
if (Math.abs(percent) > 1) {
this.navCtrl.push(NextPage,{param:item},{ animate: true, direction: 'forward' })
}
}
Run Code Online (Sandbox Code Playgroud)
使用它
<ion-item-sliding *ngFor="let item of items "(ionDrag)="ondrag($event, item)"></ion-item-sliding>
Run Code Online (Sandbox Code Playgroud)
我得到的行为是,当我滑动太远时,它会多次调用并推送页面(我猜多少事件和我一样)
有关如何正确实现这一点的任何建议?
谢谢!
我有一个包含3个元素的页面.第一个搜索栏,第二个搜索结果区和第三个表单.所以这里的用例就像是,默认搜索栏和表格div将显示并隐藏搜索结果div.如果我在搜索栏上输入密钥,那么我将获取客户端数据,因此要隐藏表单栏并显示搜索栏结果.在搜索var结果中,如果我单击任一项(客户端),则隐藏搜索结果并显示表单div.然后我想在表单字段中填写点击的客户端名称,我是angularjs中的新用户请帮助我.
<ion-view title="Client Details" id="page5" ng-init="isSearch=false;isForm=true;" style="background-color:#F1F8E9;">
<ion-content padding="true" class="has-header">
<label class="item item-input">
<i class="icon ion-search placeholder-icon"></i>
<input type="search" ng-model="str" ng-change="searchByName(str)" placeholder="Search Client">
</label>
<ion-list ng-show="{{isSearch}}" id="home-list2">
<ion-item ng-repeat="client in clientList" id="home-list-item2" ng-click="str=true">{{client.name}}</ion-item>
</ion-list>
<form ng-show="{{isForm}}" id="clientDetails-form1" class="list ">
<label class="item item-input item-floating-label" id="clientDetails-input1">
<span class="input-label">Name</span>
<input type="text" placeholder="Name">
</label>
</form>
</ion-content>
Run Code Online (Sandbox Code Playgroud)
我的控制器文件是
(function() {
var app = angular.module('clientdetailsctrl', ['clientdetailsservice']);
app.run(function($rootScope, $state, ClientDetails) {
});
app.controller('ClientDetailsCtrl', function($scope, $rootScope, $state, ClientDetails) {
$scope.searchByName = function(str) {
$scope.isSearch = true;
$scope.isForm = …Run Code Online (Sandbox Code Playgroud) ionic-framework ×10
cordova ×3
android ×2
angular ×2
angularjs ×2
html ×2
ionic2 ×2
javascript ×2
typescript ×2
apk ×1
crosswalk ×1
css ×1
firebase ×1
html5 ×1
ionic-view ×1
ionic3 ×1
json ×1
php ×1