Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/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 如何更新$(';选择';).material_select();$http完成后_Angularjs_Select_Materialize_Angular Http - Fatal编程技术网

Angularjs 如何更新$(';选择';).material_select();$http完成后

Angularjs 如何更新$(';选择';).material_select();$http完成后,angularjs,select,materialize,angular-http,Angularjs,Select,Materialize,Angular Http,我使用的是angular和materializecss()。我想在$http完成更新后材料\u select()但找不到任何解决方案 到目前为止我已经试过了: 1> $('select').material_select(); 2> $(element).material_select(); 有人能提出解决办法吗 提前感谢。使用以下步骤解决您的答案: $http({ method: "POST", url: '/xxxxxxx', data: { type:

我使用的是angular和materializecss()。我想在$http完成更新后
材料\u select()
但找不到任何解决方案

到目前为止我已经试过了:

1> $('select').material_select();

2> $(element).material_select();
有人能提出解决办法吗


提前感谢。

使用以下步骤解决您的答案:

 $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>


你说的是哪一个$http调用?我正在通过angular和on
调用一个
ajax
。成功
我正在使用初始化函数。你是否在中调用了material_select()。你的$http调用成功了吗?是的,但我不知道如何调用。我可以使用选择器,但为什么要使用超时?