سلام
من یه اکشن ایجاد کردم که در ان لیست اطلاعات را از بانک می گیرم با کد زیر:
public virtual async Task<ActionResult> ListTerm()
{
Mapper.CreateMap<Term, ListTermViewModel>();
var term =await _terms.GetAllTerms();
IList<ListTermViewModel> termvm = Mapper.Map<IList<Term>,IList<ListTermViewModel>>(t erm);
var result = JsonConvert.SerializeObject(termvm, Formatting.Indented,
new JsonSerializerSettings
{
ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
});
return PartialView(Views._ListTerm, result);
}
و یه پارشیال ویو هم درست کردم که داخل اون هم کد زیر را نوشتم:
کد HTML:
<div ng-app="Myapp">
<table ng-controller="termctrl" class="table table-bordered">
<tr>
<th>#</th>
<th>نام دوره</th>
</tr>
<tr ng-repeat="term in terms">
<td>{{term.TermId}}</td>
<td>{{term.TermName}}</td>
</tr>
</table>
</div>
و یه فایل اسکریپت هم درست کردم که کدهای آن از قرار زیر است:
/// <reference path="../angular.min.js" />
var app = angular.module('Myapp', []);
app.controller('termctrl', function ($scope, $html) {
$http.get('/Term/ListTerm').success(function (data) {
$scope.terms = data;
});
});
و در فایل _Layout هم از کد زیر برای فراخوانی این اکشن استفاده کرده ام:
کد HTML:
<li>@Html.ActionLink("دوره", MVC.Term.ActionNames.ListTerm, MVC.Term.Name)</li>
ولی متاسفانه خروجی من درست نیست.
میشه راهنمایی کنید که چطوری می تونم با angularjs کار کنم ؟