我正在使用angular和materializecss(link)。我希望在$ http完整更新material_select()
之后但无法找到任何解决方案。
到目前为止我已尝试过::
1> $('select').material_select();
2> $(element).material_select();
任何人都可以建议任何解决方案。
提前致谢。
答案 0 :(得分:2)
使用以下步骤解决您的答案::
$http({
method: "POST",
url: '/xxxxxxx',
data: {
type: "1"
}
})
.success(function (result) {
//result-> [{value:1,name:val1},{}...]
$scope.choices = result;
//timeout use for resolving $digest issue of $scope
$timeout(function () {
angular.element(document).find('#mySelect').material_select();
}, 500);
});
$timeout
在您的控制器中使用此服务。
在您的DOM中,它将如下所示
<select class="" id="mySelect" material-select ng-model="accountType" ng-options="item.value as item.name for item in choices">
</select>