我正在使用Ionic框架来创建一个应用程序.
我需要能够重用和更改我的应用程序标头,所以我使用我的工作标记将我的两个不同的标头声明为指令.
app.directive('headerSidebar', function(){
return {
templateUrl: 'templates/header-main.html',
restrict: 'E'
};
});
app.directive('headerBack', function(){
return {
templateUrl: 'templates/header-back.html',
restrict: 'E'
};
});
Run Code Online (Sandbox Code Playgroud)
当我尝试调用指令时<header-sidebar></header-sidebar>或<header-back></header-back>没有任何反应.
我的HTML是有效的,我的模板网址是正确的.我试过更改我的指令和模板的名称,但没有任何效果.
我正在使用Ionic侧边栏布局,我在我的内部调用我的指令ion-nav-view:
<body ng-app="starter">
<ion-side-menus>
<ion-side-menu-content>
<ion-nav-view></ion-nav-view>
</ion-side-menu-content>
<sidebar></sidebar>
</ion-side-menus>
</body>
Run Code Online (Sandbox Code Playgroud)
有关如何解决此问题或重新组织我的代码以更好地包含标题栏的任何建议?
在具有Ionic的AngularJS中,我希望能够从不同的控制器调用一个模态,而不必复制与模态相关的代码.
以下是如何创建模态(缩写为http://learn.ionicframework.com/formulas/making-modals/).
HTML:
<div class="card" ng-controller='MainCtrl' ng-click="openModal()">
Click here to open the modal
</div>
Run Code Online (Sandbox Code Playgroud)
JS:
app.controller('MainCtrl', function($scope, $ionicModal)
{
$ionicModal.fromTemplateUrl('contact-modal.html', {
scope: $scope,
animation: 'slide-in-up'
}).then(function(modal) {
$scope.modal = modal
})
$scope.openModal = function() {
$scope.modal.show()
}
// functions for this modal
// ...
})
Run Code Online (Sandbox Code Playgroud)
现在这一切都很好,但是如果我想从不同的控制器打开具有相同功能的相同模态,我将不得不复制与之相关的所有代码.
我如何抽象这个以使我的模态可以从不同的控制器重用和调用?
理想情况下,我希望每个模态都有自己的"控制器"(或类似的概念),而不是必须将其所有代码放入控制器中,无论打开它的是什么.
我的插件有问题.当我在应用程序中,并且我通过Parse发送通知时,我会收到一条带有该消息的警报(这可以按预期工作).但是,当应用程序在后台时,手机上不会显示任何内容.以下是我如何使用插件,以及如何处理通知:
var gmcId = "xxxxxxx";
var androidConfig = {
senderID: gmcId
};
document.addEventListener("deviceready", function(){
$cordovaPush.register(androidConfig).then(function(result) {
console.log("result: " + result);
}, function(err) {
// Error
})
$rootScope.$on('$cordovaPush:notificationReceived', function(event, e) {
switch( e.event )
{
case 'registered':
if ( e.regid.length > 0 )
{
// Your GCM push server needs to know the regID before it can push to this device
// here is where you might want to send it the regID for later use.
console.log("regID = " + e.regid); …Run Code Online (Sandbox Code Playgroud) 我正在使用overflow-scroll = "true"离子使用原生滚动:
<ion-content overflow-scroll = "true">
<ion-list>
<ion-item ng-repeat="foo in bar">
{{foo.label}}
</ion-item>
</ion-list>
</ion-content>
Run Code Online (Sandbox Code Playgroud)
这真的很棒(表演真的很棒).唯一的问题是(垂直)滚动条消失了.
按照该文件,我尝试添加scrollbar-y="true"到ion-content,但没有奏效.
我也尝试将其添加到我的CSS中:
::-webkit-scrollbar {
-webkit-appearance: none;
}
::-webkit-scrollbar:vertical {
width: 11px;
}
::-webkit-scrollbar:horizontal {
height: 11px;
}
::-webkit-scrollbar-thumb {
border-radius: 8px;
border: 2px solid white;
background-color: rgba(0, 0, 0, .5);
}
::-webkit-scrollbar-track {
background-color: #fff;
border-radius: 8px;
}
Run Code Online (Sandbox Code Playgroud)
......但那也没有用.
这篇文章(寻找"原生滚动")说,问题可以用css解决.
有谁知道怎么做?
我一直在做我的研究,似乎这在Ionic社区中并不是一个不常见的问题或问题.我有一个带有视图输入的简单表单:
<input type="text" id="firstName" placeholder="First Name" ng-model="registerData.firstName">
...
Run Code Online (Sandbox Code Playgroud)
在我的控制器中,我尝试着重于该领域:
document.getElementById("firstName").focus();
Run Code Online (Sandbox Code Playgroud)
当然它不起作用,所以我看到的一些帖子建议,我必须添加Ionic Keyboard Plugin.我这样做是通过运行:
cordova plugin add https://github.com/driftyco/ionic-plugins-keyboard.git
Run Code Online (Sandbox Code Playgroud)
然后我显然必须在我config.xml身上设置这个:
<preference name="KeyboardDisplayRequiresUserAction" value="false"/>
<feature name="Keyboard">
<param name="ios-package" onload="true" value="IonicKeyboard"/>
</feature>
Run Code Online (Sandbox Code Playgroud)
显然一切都应该有效......但事实并非如此.有什么我想念的吗?
在我的ionic/angularjs应用程序中,如果我点击离子列表卡项目,我会在iOS 9上的过滤机制上出现一些错误.
我得到的错误:
错误:[$ rootScope:infdig] 10 $ digest()迭代达成.中止!观察者在最近5次迭代中被解雇:[]
只有当我点击一个条目或者从该条目点击后退时才会发生这种情况.在iOS8上一切正常.
谢谢你的帮助
这里有一个建议:https://github.com/btford/angular-socket-io/issues/127
确保你有socket.io客户端库:
bower install socket.io-client --save
Run Code Online (Sandbox Code Playgroud)这并没有解决我的同样错误的问题.
包括在index.html中:
script src="lib/angular-socket-io/socket.js"
Run Code Online (Sandbox Code Playgroud)在app.js
angular.module('starter', ['ionic', 'starter.controllers', 'starter.services',
'starter.directives', 'btford.socket-io'])
Run Code Online (Sandbox Code Playgroud)在services.js
.factory('seatStatusSocket',function(socketFactory){
var myIoSocket = io.connect(porturl); // io is not defined here, suddenly.
Run Code Online (Sandbox Code Playgroud)之前它正在使用lib的远程副本.当这个错误开始时,我更改了index.html以链接本地副本,因为这个远程版本也收到了Bad Gateway错误(现在很好,但仍然没有定义socket io如上所述).
删除:
script src="http://chat.socket.io/socket.io/socket.io.js"
Run Code Online (Sandbox Code Playgroud)
版本
socket.io@1.3.7 node_modules/socket.io
node --version
v0.12.7
Run Code Online (Sandbox Code Playgroud) 我做了很多谷歌搜索,似乎没有得到很多答案,在Ionic 2中调用Cordova插件的语法是如何工作的.
例如,在Ionic 1中:我使用的是facebook插件,我会称之为:$ cordovaFacebook.login(["public_profile","email","name","last_name","first_name","birthday" ","age_range","link"]).then(function(success){
我也会"注入"它并将其添加为依赖项.这两件事我不知道如何处理Ionic 2.
我在某处看到Ionic 2并不是那么严重,但我仍然不确定
我有一个离子应用程序,其中启动屏幕和使用CLI命令生成的图标 ionic resources
iOS版本与正在渲染的启动画面完美配合,但在Android版本中,加载应用程序时只显示白屏.
我检查了config.xml文件,所有路径看起来都是正确的,生成的图像出现在相应的文件夹中.(我使用了splash.psd模板来生成它们.
我错过了什么?
这是config.xml供参考的文件,我觉得我在这里做错了 -
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<widget id="com.ionicframework.testeduser720691" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>Tested Health</name>
<description>
An Ionic Framework and Cordova project.
</description>
<author email="you@example.com" href="http://example.com.com/">
Your Name Here
</author>
<content src="index.html"/>
<access origin="*"/>
<preference name="webviewbounce" value="false"/>
<preference name="UIWebViewBounce" value="false"/>
<preference name="DisallowOverscroll" value="true"/>
<preference name="android-minSdkVersion" value="16"/>
<preference name="BackupWebStorage" value="none"/>
<preference name="SplashScreen" value="screen"/>
<preference name="SplashScreenDelay" value="3000"/>
<feature name="StatusBar">
<param name="ios-package" value="CDVStatusBar" onload="true"/>
</feature>
<platform name="android">
<icon src="resources/android/icon/drawable-ldpi-icon.png" density="ldpi"/>
<icon src="resources/android/icon/drawable-mdpi-icon.png" density="mdpi"/>
<icon src="resources/android/icon/drawable-hdpi-icon.png" …Run Code Online (Sandbox Code Playgroud) 我跑步时发生了错误.ionic cordova platform add ios它注意到了我的信息
[ERROR] Cordova遇到错误.您可以通过直接运行上面的Cordova命令获得更多洞察力.
[错误]运行cordova平台时发生错误添加ios --save(退出代码1):
Using cordova-fetch for cordova-ios@^4.4.0
Adding zone.js project...
Error: Your zone.js platform does not have Api.js”
Run Code Online (Sandbox Code Playgroud)
我曾尝试更新ionic/cordova的版本,并重新安装了node.js和npm.But它仍然没有用.
谁能告诉我如何解决这个问题.谢谢.