我是这个角度世界的新手,我对使用双花括号{{}}和单花括号{}有点困惑,或者有时没有使用花括号来包含像指令一样的表达式
ng-class={expression}
normal data binding like{{obj.key}}
ng-hide='mydata==="red"'
我基于创建了基本应用程序 angularjs
HTML:
<div ng-app="miniapp">
<div ng-controller="Ctrl">
My name is
<input type="text"/>
Val: {{val}}
<br/>
<button ng-disabled="val">Submit</button>
</div>
Run Code Online (Sandbox Code Playgroud)
JS:
var app = angular.module('miniapp', []);
var glob;
function Ctrl($scope) {
glob = $scope;
$scope.val = false;
window.setTimeout(function() {
$scope.val = true;
}, 3000);
}
window.setTimeout(function() {
glob.val = true;
}, 3000);
Run Code Online (Sandbox Code Playgroud)
正如你所看到的那样,我尝试通过2种方式在3秒之后改变val
,true
但没有人为我工作.真奇怪.我错过了什么?
实际上我在尝试从Ajax获得响应后尝试更改值,但是假设应该是同样的问题.
谢谢,
这是我的例子:http: //jsfiddle.net/6uKAT/20/
从第1个视图看似data-ng-click
可以传递一些数据,因为在按下按钮期间应该调用方法.
但我没有看到差异.
我已经遵循了代码片段:
HTML
<input
type="button"
value="Fess"
ng-click="toggle(2)">
Run Code Online (Sandbox Code Playgroud)
要么
<input
type="button"
value="Fess"
data-ng-click="toggle(2)">
Run Code Online (Sandbox Code Playgroud)
JS
$scope.toggle = function (valueS) {
alert(valueS);
}
Run Code Online (Sandbox Code Playgroud)
两者都有效.
谢谢,
我是cordova插件开发的新手.我想写一个插件,它能够打开一个新的android激活并显示一些广告.
所以我在这里遵循一个简单的教程.这非常有效并且符合预期.
下一步是将此Android Studio Gradle项目包含在我的插件中.
我的第一次尝试:将gradle项目添加到我的cordova插件的子文件夹中,并将以下行添加到plugin.xml文件中:
<framework src="libs/Broper/build.gradle" custom="true" type="gradleReference" />
Run Code Online (Sandbox Code Playgroud)
我也尝试过:
<framework src="libs/Broper/app/build.gradle" custom="true" type="gradleReference" />
Run Code Online (Sandbox Code Playgroud)
gradova文件被cordova识别.但有些东西不起作用.所以我无法将android studio项目的类导入到我的插件java文件中.
然后一个更好的解决方案(我认为是)是添加一个AAR.但在那里,我甚至不知道如何在我的cordova插件中添加AAR.
所以,问题是:如何以正确的方式将android atudio aroject(或库)添加到我的cordova插件中?
在controller
我遵循的方法:
var isPaused = false;
$scope.switcher = function (booleanExpr, trueValue, falseValue) {
return booleanExpr ? trueValue : falseValue;
};
$scope.isPaused = function () {
return isPaused;
};
Run Code Online (Sandbox Code Playgroud)
我可以从HTML中调用它,如:
<body ng-controller="Cntrl">
...
<h4>
{{ switcher( isPaused(), 'Search Address Mode', 'Search Location Mode' )}}
</h4>
<div class="btn-group">
...
</div>
Run Code Online (Sandbox Code Playgroud)
如你isPaused()
所知,false
我得到的回报<h4>Search Location Mode</h4>
这是实用程序,因此我想将其定义为 factory
feederliteModule.factory('switcher', function () {
return {
sw: function (booleanExpr, trueValue, falseValue) {
return booleanExpr ? trueValue : falseValue;
}
};
}); …
Run Code Online (Sandbox Code Playgroud) 我有2个数组:
var list:Array<Int> = [1,2,3,4,5]
var findList:Array<Int> = [1,3,5]
Run Code Online (Sandbox Code Playgroud)
我想确定list
Array是否包含所有findList
元素.
顺便说一下,元素也可以String
是其他类型.
怎么做?
我知道Swift提供的contains
方法适用于一个项目.
我将现有的自定义插件转换为Swift语言:
(位于下方Plugins/CustomPluginInSwift.swift
)
import Foundation
class CustomPluginInSwift : CDVPlugin {
func getSettings(command: CDVInvokedUrlCommand) {
println("CustomPluginInSwift :: getSettings is called")
var pluginResult = CDVPluginResult(status: CDVCommandStatus_OK)
commandDelegate.sendPluginResult(pluginResult, callbackId:command.callbackId)
}
}
Run Code Online (Sandbox Code Playgroud)
我有两个问题:
CDVPlugin
未找到CustomPluginInSwift
::CDVPlugin类CustomPluginInSwift(pluginName:CustomPluginInSwift)不存在
我离开config.xml
了同样但它没有按预期工作.
我的问题在哪里?
我想在我的iOS项目中添加Crashlytics插件,要求添加Run script
阶段.但无论我做什么 - 为了添加构建阶段,所有选项都被禁用:
我运行Xcode 6
我试图通过使用加载所有日历事件block
,有时(0.5%率)我得到NSInvalidArgumentException
崩溃的原因:
var allCals = _eventStore.calendarsForEntityType(EKEntityTypeEvent)
var predicate:NSPredicate! = _eventStore.predicateForEventsWithStartDate(yearsAgo, endDate:toAgo, calendars:allCals)
_eventStore.enumerateEventsMatchingPredicate(predicate, usingBlock:{
(event:EKEvent!, stop:UnsafeMutablePointer<ObjCBool>) in
if (event.title != nil
&& event.calendar != nil
&& event.calendar.calendarIdentifier != nil
&& event.lastModifiedDate != nil
){
if event.attendees != nil{ // < -- SOMETIMES LEADS TO CRASH!!
//...
}
else{ // standalone
//...
}
}
//......
})// end block
Run Code Online (Sandbox Code Playgroud)
完整堆栈跟踪:[线程崩溃+异常]
Thread : Fatal Exception: NSInvalidArgumentException
0 CoreFoundation 0x2917649f __exceptionPreprocess + 126
1 libobjc.A.dylib 0x36970c8b objc_exception_throw + 38 …
Run Code Online (Sandbox Code Playgroud) 我想知道为什么LinkedList
没有initialCapacity
.
我知道什么时候使用ArrayList
,何时使用LinkedList
.
定义Collection最终大小的好习惯如下:
List<String> arraylist = new ArrayList<String>(5);
Run Code Online (Sandbox Code Playgroud)
对于LinkedList
例如:
List<String> linkedlist = new LinkedList<String>(); // right way
Run Code Online (Sandbox Code Playgroud)
但
List<String> arraylist = new LinkedList<String>(5); // compilation error
Run Code Online (Sandbox Code Playgroud)
有人可以就这个问题传播一下吗?
[编辑]
顺便说一句,我可以写
List<String> arraylist = new ArrayList<String>(5);
List<String> linkedlist = new LinkedList<String>(arraylist);
Run Code Online (Sandbox Code Playgroud)