Angularjs makequestion add of simple way a question in your page
-
Include
jquery.js
. It should be located atbower_components/jquery/
. -
Include
angular.js
. It should be located atbower_components/angularjs/
. -
Include
makequestion.js
provided by this component into your app. -
Add
esouza.makequestion
as a module dependency to your app. -
Create an object question in your controller to bind it on directive esz-makequestion:
$scope.item = {
id: 1,
text: 'make question #input awesome',
answers: 'is'
};
- Insert the
esz-makequestion
directive into your template and bind object question:
<esz-makequestion question="item"></esz-makequestion>
You can call method calcScore
to calculate how many question were correct, use eszMakeQuestionService as a dependency to your controller:
angular.module('myApp', ['esouza.makequestion'])
.controller('myController', function($scope, eszMakeQuestionService) {
$scope.question = eszMakeQuestionService;
});
<a ng-click="question.calcScore()">calc score</a>
{{ question.score }}
MIT