2

my application view is split up in public and private questions.

users can see all public questions by clicking on "Show all public" questions, and the same for private questons.

i use ng-view in my main app.html, and use the show_all.html template which takes 2 arrays (private&public questions) and does ng-repeat to list all questions.

that all works fine.

the problem is, i have search which should basically take in the ng-model, run a search & update the view with the search results (search results returning data in the same format that the public questions and private questions JSON format is).

I'm not sure whether I'm using Ng-view the right way, or why this isn't even working.

Plunker URL: http://plnkr.co/edit/Ol3h0CHYAeZwBfLtb9Pt?p=streamer

4

1 回答 1

1

您需要让 Angular 知道重新处理自己。在 Angular 之外发生的任何事情都需要您告诉 Angular 进行更新。因此,在您的情况下,在更新 searchQuestions 后直接添加一个 $apply() 调用

 $scope.searchQuestions()
 $scope.$apply();

以下是有关 $apply 方法的文档: http ://docs.angularjs.org/api/ng.$ro​​otScope.Scope#$apply

于 2012-12-20T01:36:30.027 回答