我正在构建一个将包含在页面中的工具栏.它将被包括在内的div将默认为display:none.有没有办法我可以在我的工具栏上放置一个事件监听器,以便在它变得可见时进行监听,以便初始化?或者我是否必须从包含页面传递变量?
谢谢
有一个我无法修改的程序集(供应商提供),它有一个方法返回一个对象类型,但实际上是一个内部类型.
如何从程序集中访问对象的字段和/或方法?
请记住,我无法修改供应商提供的程序集.
从本质上讲,这就是我所拥有的:
来自供应商:
internal class InternalClass
public string test;
end class
public class Vendor
private InternalClass _internal;
public object Tag {get{return _internal;}}
end class
Run Code Online (Sandbox Code Playgroud)
从我使用供应商组件的装配.
public class MyClass
{
public void AccessTest()
{
Vendor vendor = new Vendor();
object value = vendor.Tag;
// Here I want to access InternalClass.test
}
}
Run Code Online (Sandbox Code Playgroud) 我有一个服务,它返回一个observable,它向我的服务器发送一个http请求并获取数据.我想使用这些数据,但我总是得到undefined.有什么问题?
服务:
@Injectable()
export class EventService {
constructor(private http: Http) { }
getEventList(): Observable<any>{
let headers = new Headers({ 'Content-Type': 'application/json' });
let options = new RequestOptions({ headers: headers });
return this.http.get("http://localhost:9999/events/get", options)
.map((res)=> res.json())
.catch((err)=> err)
}
}
Run Code Online (Sandbox Code Playgroud)
零件:
@Component({...})
export class EventComponent {
myEvents: any;
constructor( private es: EventService ) { }
ngOnInit(){
this.es.getEventList()
.subscribe((response)=>{
this.myEvents = response;
});
console.log(this.myEvents); //This prints undefined!
}
}
Run Code Online (Sandbox Code Playgroud) 我读了一些关于Lucene的文件; 我也阅读了这个链接中的文档(http://lucene.sourceforge.net/talks/pisa).
我真的不明白Lucene如何索引文档并且不了解Lucene用于索引的算法?
在上面的链接中,它表示Lucene使用此算法进行索引:
- 增量算法:
- 维护一堆段索引
- 为每个传入文档创建索引
- 将新索引推入堆栈
- 令b = 10为合并因子; M = 8
for (size = 1; size < M; size *= b) {
if (there are b indexes with size docs on top of the stack) {
pop them off the stack;
merge them into a single index;
push the merged index onto the stack;
} else {
break;
}
}
Run Code Online (Sandbox Code Playgroud)
该算法如何提供优化的索引?
Lucene是否使用B树算法或任何其他算法进行索引 - 或者它是否具有特定算法?
我发现了一些使用c#async/ awaitkeywords的异步编程的最佳实践(我是c#5.0的新手).
给出的建议之一是:
稳定性:了解同步上下文
...某些同步上下文是不可重入和单线程的.这意味着在给定时间内只能在上下文中执行一个工作单元.一个例子是Windows UI线程或ASP.NET请求上下文.在这些单线程同步上下文中,很容易使自己陷入僵局.如果从单线程上下文中生成任务,然后在上下文中等待该任务,则等待代码可能会阻止后台任务.
public ActionResult ActionAsync()
{
// DEADLOCK: this blocks on the async task
var data = GetDataAsync().Result;
return View(data);
}
private async Task<string> GetDataAsync()
{
// a very simple async method
var result = await MyWebService.GetDataAsync();
return result.ToString();
}
Run Code Online (Sandbox Code Playgroud)
如果我自己尝试剖析它,主线程会产生一个新线程MyWebService.GetDataAsync();,但由于主线程在那里等待,它等待结果GetDataAsync().Result.同时,说数据准备好了.为什么主线程不继续它的延续逻辑并从中返回字符串结果GetDataAsync()?
有人可以解释一下为什么上面的例子中存在死锁吗?我完全不知道问题是什么......
这属于select2版本4之前的代码
我有一个简单的代码,select2从ajax获取数据
$("#programid").select2({
placeholder: "Select a Program",
allowClear: true,
minimumInputLength: 3,
ajax: {
url: "ajax.php",
dataType: 'json',
quietMillis: 200,
data: function (term, page) {
return {
term: term, //search term
flag: 'selectprogram',
page: page // page number
};
},
results: function (data) {
return {results: data};
}
},
dropdownCssClass: "bigdrop",
escapeMarkup: function (m) { return m; }
});
Run Code Online (Sandbox Code Playgroud)
此代码正常工作,但是,我需要在其上设置一个值,就像在编辑模式下一样.当用户第一次选择一个值时,它将被保存,当他需要编辑该值时,它必须出现在同一个选择菜单(select2)中,以选择之前选择的值,但我找不到方法.
更新:
HTML代码:
<input type="hidden" name="programid" id="programid" class="width-500 validate[required]">
Run Code Online (Sandbox Code Playgroud)
Select2编程访问不适用于此.
在Linq中是否有一个方法可用于构建SQL字符串,如"... where(a = 1)OR(a = 2)"?
是否有方法或属性从对象中获取所有方法?例如:
function foo() {}
foo.prototype.a = function() {}
foo.prototype.b = function() {}
foo.get_methods(); // returns ['a', 'b'];
Run Code Online (Sandbox Code Playgroud)
更新:在Jquery中有类似的方法吗?
谢谢.
如何使用Font Awesome中包含的搜索图标进行输入?我的网站上有一个搜索功能(基于PHPmotion),我想用于搜索.
这是代码:
<div id="search-bar">
<form method="get" action="search.php" autocomplete="off" name="form_search">
<input type="hidden" name="type" value="videos" />
<input autocomplete="on" id="keyword" name="keyword" value="Search Videos" onclick="clickclear(this,
'Search Videos')" onblur="clickrecall(this,'Search Videos')" style="font-family: verdana; font-weight:bold;
font-size: 10pt; height: 28px; width:186px; color: #000000; padding-left: 2px; float:left; border: 1px solid black; background-color:
#ffffff" />
<input type="image" src="http://viddir.com/themes/default/images/search.jpg" height="30" width="30" border="0" style="float:right;"/>
<div id="searchBoxSuggestions"></div>
</form>
</div>
Run Code Online (Sandbox Code Playgroud) javascript ×4
c# ×2
.net ×1
ajax ×1
algorithm ×1
angular ×1
async-await ×1
asynchronous ×1
c#-5.0 ×1
class ×1
css ×1
css3 ×1
deadlock ×1
font-awesome ×1
function ×1
get ×1
git ×1
git-push ×1
html ×1
html5 ×1
indexing ×1
jquery ×1
linq ×1
lucene ×1
methods ×1
object ×1
observable ×1
php ×1
typescript ×1
where-clause ×1