AngularJS: Different Views and Different Controller by Data -
lets assume want make quiz page. have different question types. i.e. task find right order, choose 1 answer, choose multiple answers, or fill spaces predefined words , on. so, have 5 questions in data context. 2 of them multiple-choice, 1 right order question , other 2 clozes. main point is: have no clue how many different question types in current quiz. of them need own view, own controller , own data model, because there no universal data model applies clozes , right-order-questions @ same time (correct me, if wrong).
what best way in angularjs , mvc-pattern in general this? applicable? contradicts mvc-pattern in general?
so have 5 questions, i'd ng-repeat on questions , ng-switch on each of views want.
<div ng-repeat="question in questions" ng-switch="question.questiontype"> <div ng-switch-when="multiplechoice" ng-controller="multiplechoicectrl"> ... multiple choice </div> <div ng-switch-when="rightorder" ng-controller="rightorderctrl"> ... right order </div> </div>
Comments
Post a Comment