我是angularjs的初学者,有一些关于控制器的问题.
这是我的示例控制器:
function exampleController($scope)
{
$scope.sampleArray = new Array();
$scope.firstMethod = function()
{
//initialize the sampleArray
};
$scope.secondMethod = function()
{
this.firstMethod();
};
};
Run Code Online (Sandbox Code Playgroud)
这是我的问题:
firstMethod的secondMethod?我的方式是正确的,还是更好的方式?我的xml如下:
<?xml version="1.0" encoding="UTF-8"?>
<root>
<data name="LogIn">Log In</data>
<data name="Password">Password</data>
</root>
Run Code Online (Sandbox Code Playgroud)
我没有Linq成功做到这一点,任何人都可以帮我将以下代码转换为Linq:
using (XmlReader reader = XmlReader.Create(_xml))
{
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.Element && reader.LocalName == "data")
{
reader.MoveToAttribute("name");
string key = reader.Value;
reader.MoveToContent();
string value = reader.ReadElementContentAsString();
_dictionary.Add(key, value);
}
}
reader.Close();
}
Run Code Online (Sandbox Code Playgroud) 我有以下课程:
export class Test {
private _rowsCount: string;
public get RowsCount(): string {
return this._rowsCount;
};
public set RowsCount(value: string) {
this._rowsCount = value;
};
private _rowsCount2: string;
public get RowsCount2(): string {
return this._rowsCount2;
};
public set RowsCount2(value: string) {
this._rowsCount2 = value;
};
}
Run Code Online (Sandbox Code Playgroud)
我需要迭代特定类中的属性,我尝试了以下内容:
Object.keys(this).forEach((key)=> {
console.log(key);
});
Run Code Online (Sandbox Code Playgroud)
但是这个问题只是在private字段上进行迭代,我也尝试了以下我得到了所有的methods和properties:
for (var property in this) {
if (this.hasOwnProperty(property)) {
console.log(property);
}
}
Run Code Online (Sandbox Code Playgroud)
有没有人有办法解决吗?
谢谢!
我有以下代码:
<table class="table">
<tr>
<th>Name___</th>
</tr>
<tr ng-repeat="app in apps"
ng-click="go('/editApp/' + plugin.name);">
<td>
<span>{{app.name}}</span>
</td>
<td style="width: 100px;">
<i class="glyphicon glyphicon-pencil"
ng-click="openPopup(app)"></i>
</td>
</tr>
</table>
Run Code Online (Sandbox Code Playgroud)
当我点击OpenPopup时,go()方法也会触发,我怎么能这样做,如果我点击弹出窗口就会触发弹出窗口?
我试图在javascript中解析url,我找到了以下方法:
var getLocation = function(href) {
var l = document.createElement("a");
l.href = href;
return l;
};
var l = getLocation("http://example.com:3000/path");
var host = l.host; // example.com
var port = l.port; // 3000
Run Code Online (Sandbox Code Playgroud)
但是如果这些地方我遇到了问题:
http://TLVS0015:3000/cti/YTest // the parse found the port, but its not found the host
http://ctmwe:80/ReportServer/ReportService2010.asmx // the parse found the host, but don't found the port
Run Code Online (Sandbox Code Playgroud)
还有其他方法可以解析吗?
我在HTML中有以下代码:
<div class="col-sm-12">
<div ng-repeat="param in plugin.wsdlURLs track by $index" class="col-sm-12">
<select class="form-control col-sm-4" ng-model="test" ng-options="lOrU for lOrU in localOrUrl">
</select>
<input type="url" class="form-control col-sm-8 invalidInput">
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
我遇到了一个问题,当我放一个form-control类时,它将显示select在一行中,而input在另一行中.我想保留form-control课程,select并input在同一行显示.我知道问题来自于form-control,因为宽度是100%
css html5 twitter-bootstrap angular-ui-bootstrap twitter-bootstrap-3
我们有一个"logger"类,它具有获取日志消息的log方法,并将消息和调用方法写入日志,首先我们还要将以下内容发送给log方法新参数Method.Base.GetCurrentMethod().我找到了另一种方法,使用Relection.MethodBase:
public void Log(string message)
{
stackTrace = new StackTrace();
string methodName = stackTrace.GetFrame(1).GetMethod().Name;
....
}
Run Code Online (Sandbox Code Playgroud)
但我有一个问题,每次调用log方法,我都被迫创建新实例StackTrace,当我尝试在构造函数中创建实例时,我得到方法名称InvokeMethod.
我们在项目中使用MEF.任何想法如何改进代码?
我有一个string[].我想做的是转换string[]为ObservableCollection<string>.
javascript ×4
angularjs ×3
c# ×3
html5 ×2
.net ×1
c#-4.0 ×1
casting ×1
css ×1
linq ×1
linq-to-xml ×1
mef ×1
parsing ×1
stack-trace ×1
typescript ×1
url ×1
xml ×1