我想从索引视图调用我的服务器,并将模型从服务器带到视图
我已经完成但是这不起作用请告诉我该怎么做
这就是我所做的
var app = angular.module('app', []);
var CreateController = ['$scope','$http', function ($scope, $http) {
$scope.model = {};
$scope.mydata = 'ajs works';
$http.get('/Testing/Index').success(function(data){
$scope.model = data;
})
.error(function(data){
console.log("error");
});
}];
app.controller('CreateController', CreateController);
这是索引视图
<div ng-controller="CreateController">
<table class="ui-sortable-handle">
<tr>
<td>
<input type="hidden" id="qid" value="{{model.Questions.AddQuestionID}}" />
</td>
</tr>
<tr>
<td>
<input type="hidden" id="complevel" value="{{model.Questions.ComplexityLevel}}" />
<input type="hidden" id="servcomplvl" value="{{model.servercomplevel}}" />
</td>
</tr>
<tr>
<td>
<h3>Question: {{model.Questions.Question}}</h3>
</td>
</tr>
<tr ng-repeat="item in model.Options">
<td class="switch radius">
<input id="{{item.Options}}" type="radio" name="selectedvalue" value="{{item.Options}}">
<label for="{{item.Options}}"></label>{{item.Options}}
</td>
</tr>
</table>
我从视野中返回的是
return View(vm);