Html代码
<select id="dropdwon1">
<option value="1">Item1</option>
<option value="2">Item2</option>
<option value="3">Item3</option>
</select>
<select id="dropdwon2"></select>
Run Code Online (Sandbox Code Playgroud)
我需要使用jQuery将所有选项从dropdown1复制到dropdown2.是否可以简单地复制内容?
此刻我正致力于巨大的角度SPA应用.我试着保持我的控制器很薄:
<div ng-controller='HomeController as home'>
<div ng-repeat='var item in home.items' ng-bind='item' ></div>
<button ng-click='home.remove(1)' >remove</button>
</div>
function HomeController (homeService){
var vm = this; //$scope
vm.items = [1,2,3,4,5];
vm.remove = remove;
function remove (id){
homeService.remove({ items: vm.items, targetId: id });
}
//a lot of other logic here
}
angular.module('my').service('homeService', homeService);
function homeService (){
this.remove = remove;
function remove (param){
for(var a = 0; a < param.items.length; a++){
if(param.items[a] == param.targetId){
param.items.splice(a, 1);
break;
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
好处:
缺点:
JavaScript的\ jQuery的:
var items = new Array();
var obj { Begin: "444", End: "end" };
items.push(obj);
items.push(obj);
var request = {
DateStart: $("#DateStart").val(),
mass: items
};
$.post("/Home/Index", request, null,
"json");
Run Code Online (Sandbox Code Playgroud)
C#Mvc索引控制器
public class MyClass
{
public string Begin;
public string End;
}
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Index(
string DateStart,
MyClass []mass)
{
System.Diagnostics.Debug.WriteLine(mass[0].Begin);
}
Run Code Online (Sandbox Code Playgroud)
如何执行此代码?谢谢.
任何人都可以解释,为什么这段代码返回abc,True?
var str1 = "abc";
var str2 = "";
var builder = new StringBuilder();
builder.Append("a");
builder.Append("b");
builder.Append("c");
str2 = builder.ToString();
Console.WriteLine(string.IsInterned(str2));
Console.WriteLine(str1.Equals(str2));
Run Code Online (Sandbox Code Playgroud)
我用反射器看StringBuilder.ToString()方法但是找不到任何使用string.Intern的方法.
我使用的是Net Framework 4.5