我有一个datagridview是一个完整的行选择.如果点击行中的哪个单元格,我将如何仅从某个单元格中获取数据,因为它突出显示整行.
假设我有以下元素:
<div class="home">
<div class="tab231891230"></div>
<div class="tab121232441"></div>
<div class="tab123134545"></div>
</div>
Run Code Online (Sandbox Code Playgroud)
如何使用jQuery选择类开头的div元素"tab"?
我试图返回一个json结果(数组); 如果我手动执行它可以工作
resources:[
{
name: 'Resource 1',
id: 1,
color:'red'
},{
name: 'Resource 2',
id: 2
}],
Run Code Online (Sandbox Code Playgroud)
但我通过传递它有渲染问题:
在视图上:
resources:@Model.Resources
Run Code Online (Sandbox Code Playgroud)
哪个在控制器上
public ActionResult Index()
{
...
var model = new Display();
model.Resources = GetResources();
}
public JsonResult GetResources()
{
var model = new Models.ScheduledResource()
{
id = "1",
name = "Resource"
};
return new JsonResult() { Data = model, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
}
Run Code Online (Sandbox Code Playgroud)
在模型上
public JsonResult Resources { get; set; }
Run Code Online (Sandbox Code Playgroud)
但看看在html中呈现的是什么:
resources:System.Web.Mvc.JsonResult
Run Code Online (Sandbox Code Playgroud)
我出错了什么想法?
用谷歌搜索后,我找到了两个解决方案:
var data = [...Array(10).keys()];
console.log(data);
var data1 = Array(8).fill().map((_, i) => i);
console.log(data1);Run Code Online (Sandbox Code Playgroud)
data1显示[0,1,...,7]但是数据只显示[[object Array Iterator]]我如何实际看到数字.
我需要它来对数字进行一些迭代(Euler项目的一部分).
以前我在Python中做了很多Euler挑战.现在我决定重新访问它并尽可能多地使用JS(尽可能多的ES6语法)来帮助我发展我的js技能.
我有一个表格:
<form method="POST" action="submit.php">
<input type="text" value="1">
<input type="text" value="2">
<input type="text" value="3">
<input type="text" value="4">
<button type="submit">Submit</button>
</form>
Run Code Online (Sandbox Code Playgroud)
如何在表单中循环输入元素(以便对它们执行某些验证)?
我更喜欢只使用纯JavaScript,而不是jQuery或其他库.我还想限制迭代以形成元素,而不是可以添加到表单的任何其他元素.
刚接受采访.第一个问题问我是什么console.log().我非常自信地回答.再次,
第二个问题是,window.console.log()和之间有什么区别console.log().我无言以对.尝试在Google和Stack Overflow中搜索.我没有找到这样有用的帖子来理解它们之间的区别.
任何想法都非常感谢.
我正在使用visual studio代码进行处理.一切都运转良好,但我不能得到一个具体的工作.
我需要能够从文本中删除换行符.
例:
first line
second line
Run Code Online (Sandbox Code Playgroud)
应该成为:
first linesecondline
Run Code Online (Sandbox Code Playgroud)
自最近更新以来,可以使用^ $搜索换行符.它在这里描述:https://github.com/Microsoft/vscode/pull/314
我遇到的问题是,当我使用它进行替换时,它实际上"添加"到换行符并且不"替换"它.
我正在编写一个Angular2测试组件,我在教程中注意到了这一行:
de = fixture.debugElement.query(By.css('h1'));
Run Code Online (Sandbox Code Playgroud)
de被定义为DebugElement类型.
我怎么能通过DebugElement身份证?
这似乎非常简单,但我无法在文档中找到任何方向.
如何处理/提供@Input,并@Output在角2动态创建组件的属性?
这个想法是在调用createSub方法时动态创建(在这种情况下)SubComponent.分叉很好,但我如何为SubComponent中的属性提供数据.另外,如何处理/订阅SubComponent提供的事件?@Input@Output
例如: (两个部件在相同的NgModule)
AppComponent
@Component({
selector: 'app-root'
})
export class AppComponent {
someData: 'asdfasf'
constructor(private resolver: ComponentFactoryResolver, private location: ViewContainerRef) { }
createSub() {
const factory = this.resolver.resolveComponentFactory(SubComponent);
const ref = this.location.createComponent(factory, this.location.length, this.location.parentInjector, []);
ref.changeDetectorRef.detectChanges();
return ref;
}
onClick() {
// do something
}
}
Run Code Online (Sandbox Code Playgroud)
子
@Component({
selector: 'app-sub'
})
export class SubComponent {
@Input('data') someData: string;
@Output('onClick') onClick = new EventEmitter();
}
Run Code Online (Sandbox Code Playgroud) 我已经通过npm安装了angular2 cli,但是当我尝试使用'ng new my-app'命令创建一个新的typescript角度应用程序时,我不断收到此错误:
C:\Users\nicholas\AppData\Roaming\npm\node_modules\@angular\cli\models\config\config.js:15
constructor(_configPath, schema, configJson, fallbacks = []) {
^
SyntaxError: Unexpected token =
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:373:25)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (C:\Users\nicholas\AppData\Roaming\npm\node_modules\@angular\cli\models\config.js:2:18)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
Run Code Online (Sandbox Code Playgroud)
我的NPM版本是4.1.2我的节点版本是4.4.5,根据我的理解,这是安装和使用angular-cli的可接受版本.
如果有解决方法,请告诉我,我也尝试卸载,清理npm缓存并重新安装,但我一直遇到同样的问题.
任何和所有的帮助非常感谢,提前感谢!
javascript ×4
angular ×3
jquery ×2
angular-cli ×1
asp.net-mvc ×1
c# ×1
console.log ×1
datagridview ×1
ecmascript-6 ×1
forms ×1
html ×1
json ×1
node.js ×1
replace ×1
winforms ×1