Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs Ng click无法在Ng repeat中使用Ng bind html_Angularjs_Asp.net Mvc 4 - Fatal编程技术网

Angularjs Ng click无法在Ng repeat中使用Ng bind html

Angularjs Ng click无法在Ng repeat中使用Ng bind html,angularjs,asp.net-mvc-4,Angularjs,Asp.net Mvc 4,我试图在MVC4中使用Jsonresult和Angularjs获取数据 Jsonresult函数在控制器中: public JsonResult GetQuestionSets() { //... var selectedData = titles.Select(y => new { //... qsAction = y.qtConfirm.Equals(false) ? "<button type='button' class='btn btn-warning bt

我试图在MVC4中使用Jsonresult和Angularjs获取数据

Jsonresult函数在控制器中:

public JsonResult GetQuestionSets() {
//...
var selectedData = titles.Select(y => new
{
    //...
    qsAction = y.qtConfirm.Equals(false) ? "<button type='button' class='btn btn-warning btn-sm' ng-click='getQSetId(qset.qsTitleID)'>Edit</button>" : y.Questions.All(z => z.qStatus == null) ? "<button type='button' class='btn btn-success btn-sm disabled'>Waiting</button>" : y.Questions.All(z => z.qStatus == true) ? "<button class='btn btn-success btn-sm'>Preview</button>" : "<button type='button' class='btn btn-warning btn-sm'>Edit</button>",
});

return Json(selectedData, JsonRequestBehavior.AllowGet);

}
$http.get('/Tutor/GetQuestionSets').then(function (response) {
$scope.questionSets = response.data;
});
$scope.trustedHtml = $sce.trustAsHtml;// Convert string to html
<table class="table table-striped">
<thead>
    //...
</thead>
<tbody>
    <tr ng-repeat="qset in questionSets">
        //...
        <td align="center" ng-bind-html="trustedHtml(qset.qsAction)"></td>
    </tr>
</tbody>
</table>
查看:

public JsonResult GetQuestionSets() {
//...
var selectedData = titles.Select(y => new
{
    //...
    qsAction = y.qtConfirm.Equals(false) ? "<button type='button' class='btn btn-warning btn-sm' ng-click='getQSetId(qset.qsTitleID)'>Edit</button>" : y.Questions.All(z => z.qStatus == null) ? "<button type='button' class='btn btn-success btn-sm disabled'>Waiting</button>" : y.Questions.All(z => z.qStatus == true) ? "<button class='btn btn-success btn-sm'>Preview</button>" : "<button type='button' class='btn btn-warning btn-sm'>Edit</button>",
});

return Json(selectedData, JsonRequestBehavior.AllowGet);

}
$http.get('/Tutor/GetQuestionSets').then(function (response) {
$scope.questionSets = response.data;
});
$scope.trustedHtml = $sce.trustAsHtml;// Convert string to html
<table class="table table-striped">
<thead>
    //...
</thead>
<tbody>
    <tr ng-repeat="qset in questionSets">
        //...
        <td align="center" ng-bind-html="trustedHtml(qset.qsAction)"></td>
    </tr>
</tbody>
</table>

//...
//...
我的问题是:

public JsonResult GetQuestionSets() {
//...
var selectedData = titles.Select(y => new
{
    //...
    qsAction = y.qtConfirm.Equals(false) ? "<button type='button' class='btn btn-warning btn-sm' ng-click='getQSetId(qset.qsTitleID)'>Edit</button>" : y.Questions.All(z => z.qStatus == null) ? "<button type='button' class='btn btn-success btn-sm disabled'>Waiting</button>" : y.Questions.All(z => z.qStatus == true) ? "<button class='btn btn-success btn-sm'>Preview</button>" : "<button type='button' class='btn btn-warning btn-sm'>Edit</button>",
});

return Json(selectedData, JsonRequestBehavior.AllowGet);

}
$http.get('/Tutor/GetQuestionSets').then(function (response) {
$scope.questionSets = response.data;
});
$scope.trustedHtml = $sce.trustAsHtml;// Convert string to html
<table class="table table-striped">
<thead>
    //...
</thead>
<tbody>
    <tr ng-repeat="qset in questionSets">
        //...
        <td align="center" ng-bind-html="trustedHtml(qset.qsAction)"></td>
    </tr>
</tbody>
</table>

Ng单击通过json结果显示的内容
不起作用。但是,当我用简单的函数将ng click更改为onclick时,它就开始工作了。您知道原因和解决方案吗?

ng bind html处理纯DOM,而不是像
ng click
这样的角度指令。Angular不知道要包括
ngClick
来消化周期,从而监听事件。你得先去看看。或者使用它在一个地方同时完成两件事

谢谢你的回答:)angular bind html编译解决了我的问题