Skip to content

Instantly share code, notes, and snippets.

@sam452
Created August 20, 2017 20:13
Show Gist options
  • Save sam452/1a46853c6e495bcdf90772bbff6ec27b to your computer and use it in GitHub Desktop.
Save sam452/1a46853c6e495bcdf90772bbff6ec27b to your computer and use it in GitHub Desktop.
Add question
'use strict';
// Declare app level module which depends on views, and components
angular.module('myApp', [
'ngRoute',
'myApp.ProfileView',
'myApp.GroupView',
'myApp.QuestionView',
'myApp.version'
]).
config(['$locationProvider', '$routeProvider', function($locationProvider, $routeProvider) {
$locationProvider.hashPrefix('!');
$routeProvider.otherwise({redirectTo: '/profile_view'});
}]);
<section>
<div class="container" ng-controller="QuestionCtrl">
<div class="column is-one-third profile-sidebar">
<div class="form-group">
<div class="col-sm-2">
<input type="text" ng-model="Users.question" class="" id="question" placeholder="Your question here"/>
</div>
<div class="col-sm-2">
<input type="text" ng-model="Users.answer" class="" id="answer" placeholder="Your answer to this question here"/>
</div>
<button id="question-submit" ng-click="pts()" class="button is-inverted">Submit Question</button>
</div>
// <script type="text/javascript">
// document.getElementById("question").innerHTML = "";
// </script>
</div>
</div>
</section>
'use strict';
angular.module('myApp.QuestionView', ['ngRoute'])
.config(['$routeProvider', function($routeProvider) {
$routeProvider.when('/profile_view', {
templateUrl: 'profile_view/question_view.html',
controller: 'QuestionCtrl'
});
}])
.controller('QuestionCtrl', ['$scope', '$http', function($scope, $http) {
$http.get ('https://readtheroom-6b306.firebaseio.com/users/user0.json')
.then ((userObj) => {
$scope.profile = userObj.data;
var mypoints = $scope.profile.askPoints;
})
$scope.pts = function(){
$scope.profile.askPoints += 1;
console.log($scope.profile.askPoints);
}
})
// console.log("what's scope", $scope);
}]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment