dur*_*uru 10 javascript angularjs
这是我的代码
$http.get("/Student/GetStudentById?studentId=" + $scope.studentId + "&collegeId=" + $scope.collegeId)
.then(function (result) {
});
Run Code Online (Sandbox Code Playgroud)
在上面的代码中使用http服务来获取基于id的学生详细信息.但是我想在c#.net中编写上面的服务string.format
(eg:- string.format("/Student/GetStudentById/{0}/collegeId/{1}",studentId,collegeId)
Run Code Online (Sandbox Code Playgroud)
String.format = function () {
// The string containing the format items (e.g. "{0}")
// will and always has to be the first argument.
var theString = arguments[0];
// start with the second argument (i = 1)
for (var i = 1; i < arguments.length; i++) {
// "gm" = RegEx options for Global search (more than one instance)
// and for Multiline search
var regEx = new RegExp("\\{" + (i - 1) + "\\}", "gm");
theString = theString.replace(regEx, arguments[i]);
}
return theString;
}
$http.get(String.format("/Student/GetStudentById?studentId={0}&collegeId={1}", $scope.studentId , $scope.collegeId))
.then(function (result) {
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
23916 次 |
| 最近记录: |