我正在使用 ng2-dragula 并在 2 个表中进行数据绑定。当将 td 拖放到另一个表时,它会抛出 Uncaught TypeError: Cannot read property 'splice' of undefined。并且无法删除该元素。需要有关如何解决此问题的帮助。
下面是html部分
<table class="table">
<thead class="text-primary">
<tr>
<th>Task ID</th>
<th>Ref #</th>
<th>Customer Name</th>
<th>Doc Type</th>
<th>Date</th>
</tr>
</thead>
<tbody [dragula]='"team-bag"' [dragulaModel]="tasks">
<tr *ngFor="let t of tasks">
<td>{{t.id}}</td>
<td>{{t.refNbr}}</td>
<td>{{t.custName}}</td>
<td>{{t.docType}}</td>
<td>{{t.receiveDate}}</td>
</tr>
</tbody>
</table>
<table class="table">
<thead class="text-primary">
<tr>
<th>Task ID</th>
<th>Ref #</th>
<th>Customer Name</th>
<th>Doc Type</th>
<th>Date</th>
</tr>
</thead>
<tbody [dragula]='"team-bag"' [dragulaModel]="agentATasks">
<tr *ngFor="let t of agentATasks">
<td>{{t.id}}</td>
<td>{{t.refNbr}}</td>
<td>{{t.custName}}</td>
<td>{{t.docType}}</td>
<td>{{t.receiveDate}}</td>
</tr>
</tbody>
</table> …Run Code Online (Sandbox Code Playgroud)我正在尝试将文件和表格数据从Angularjs客户端上传到Web API。我在网上找到了一些参考代码,并以相同的方式实现。Web API方法中的第一行代码是if (!Request.Content.IsMimeMultipartContent())
{
throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType);
}
返回false并将失败返回给客户端。我不知道我做错了什么...
下面是我的Angularjs中的代码
var _uploadNotes = function (notes, files) {
var deferred = $q.defer();
$http({
method: 'POST',
url: "api/issue/uploadNotes",
headers: { 'Content-Type': false },
transformRequest: function (data) {
var formData = new FormData();
formData.append("model", angular.toJson(data.model));
for (var i = 0; i < data.files.length; i++) {
formData.append("file" + i, data.files[i]);
}
return formData;
},
data: { model: notes, files: files }
}).
success(function (data, status, headers, config) {
deferred.resolve();
}).
error(function (data, …Run Code Online (Sandbox Code Playgroud)我正在开发通过CLI构建的Angular 4应用程序,而后端API仍在开发中,我已经在Assets文件夹下为http.get设置了一些json文件。一切在我的本地设备上都运行良好,但是当我部署到IIS时,在开发工具的“网络”选项卡中,尝试访问json文件时会看到404。我在代码中设置URL的方式是硬编码“ assets / api / manager / model.json”。我通过运行npm build --prod构建了项目,并复制了dist文件夹中的内容。在构建后,我确实在dist下看到assets / api / manager / model.json文件。我看到在IIS上托管时,有多种方法可以对路由进行调整,我已经尝试了所有方法(我认为),但似乎无法使其正常工作。
以下是http.get代码
private assignTasksViewModelUrl = 'assets/api/manager/model.json';
getTaskAssignmentViewModel(): Observable<AssignTasksViewModel> {
return this.http.get(this.assignTasksViewModelUrl)
.map((response: Response) => <AssignTasksViewModel>(this.extractDate(response)))
.do(data => console.log(JSON.stringify(data)))
.catch(this.handleError);
}
Run Code Online (Sandbox Code Playgroud)