scttcper
1/22/2015 - 11:33 PM

angular challenge

angular challenge

<form ng-submit="submit()" ng-controller="MyController">
    <div class="row">
        <div class="large-12 columns">
            <h4>{% widget "text" "surveyname" %}</h4>
            <label>{% widget "text" "question1" %}
                <input type="text" ng-model="input.first" />
            </label>
            <label>{% widget "text" "question2" %}
                <input type="text" ng-model="input.second" />
            </label>
            <button type=submit>Go</button>
        </div>
    </div>
</form>
var app = angular.module('cApp{{challenge.id}}', []);
app.config(function($interpolateProvider){
    $interpolateProvider.startSymbol('[[').endSymbol(']]');
  });
app.controller('MyController', ['$scope', function ($scope) {
    $scope.input = {};
    $scope.submit = function(){
        console.log($scope.input);
        console.log('{{challenge.id}}');
        PT.api.call('/vote/', {
            data: {
                group_id: 'challenge_{{challenge.id}}',
                oid: 'challenge',
                value: JSON.stringify($scope.input)
            },
            method: 'post',
            success: function() {
                console.log('SUCCESS');
            }
        });
    };
}]);

angular.element(div).ready(function() {
  angular.bootstrap(div, ['cApp{{challenge.id}}']);
});