Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //(function () {
- // var app = angular.module('faqs', []);
- // app.controller('FAQController', function () {
- // console.log("hej");
- // this.faq = faq;
- // });
- // var faq = [
- // {
- // title: 'firstFAQ',
- // text: 'How do i Angular?',
- // author: 'Jag',
- // upvotes: 0,
- // },
- // {
- // title: 'firstFAQ',
- // text: 'How do i Angular?',
- // author: 'Jag',
- // upvotes: 0,
- // },
- // {
- // title: 'firstFAQ',
- // text: 'How do i Angular?',
- // author: 'Jag',
- // upvotes: 0,
- // },
- // ]
- //})();
- (function () {
- var app = angular.module('faqs', ['ngRoute']);
- app.controller('FAQController', ['$http', function ($http) {
- var fc = this;
- fc.allFAQs = [];
- fc.ClickedUpvote = ClickedUpvote;
- fc.ClickedDownvote = ClickedDownvote;
- fc.searchString = searchString;
- fc.CreateFAQ = CreateFAQ;
- fc.search = "";
- fc.GetAllFAQs = GetAllFAQs;
- function searchString(search) {
- console.log(search);
- GetAllFAQs(search);
- }
- function GetAllFAQs(search) {
- $http({
- url: "http://localhost:53227/WebServiceFAQ.asmx/GetAllFAQs",
- data: {search: search},
- dataType: "json",
- method: "POST",
- headers: {
- "Content-Type": "application/json"
- }
- }).success(function (data) {
- //console.log("hejhej");
- fc.allFAQs = data.d;
- console.log(fc.allFAQs);
- });
- }
- function CreateFAQ(author, title, text) {
- $http({
- url: "http://localhost:53227/WebServiceFAQ.asmx/CreateFAQ",
- data: { author: author, title: title, text: text },
- dataType: "json",
- method: "POST",
- headers: {
- "Content-Type": "application/json"
- }
- }).success(function (data) {
- //console.log("FAQ Created");
- });
- }
- function ClickedUpvote(faqID) {
- $http({
- url: "http://localhost:53227/WebServiceFAQ.asmx/Upvote",
- data: '',
- dataType: "json",
- method: "POST",
- headers: {
- "Content-Type": "application/json"
- }
- }).success(function (data) {
- console.log("Upvoted");
- if (data.d)
- {
- }
- //fc.allFAQs = data.d;
- });
- }
- function ClickedDownvote() {
- }
- //data: { test: 'test', test: 'test'}
- //.success bla bla if(data.d) sätt en bool till true som ger användaren access till dom andra sidorna
- fc.GetAllFAQs("");
- }]);
- app.controller('SignInController', ['$http', function ($http) {
- var fc = this;
- fc.Register = Register;
- function Register(firstname, lastname, email, phonenumber, username, password) {
- console.log("registeredededed");
- $http({
- url: "http://localhost:53227/WebServiceLogin.asmx/Register",
- data: { firstname: firstname, lastname: lastname, email: email, phonenumber: phonenumber, username: username, password: password },
- dataType: "json",
- method: "POST",
- headers: {
- "Content-Type": "application/json"
- }
- }).success(function (data) {
- console.log("User added" + username);
- });
- }
- //den returnerade boolen skall sättar i data:''?
- function SignIn(username, password) {
- $http({
- url: "http://localhost:53227/WebServiceLogin.asmx/TryToSignIn",
- data: {username: username, password: password},
- dataType: "json",
- method: "POST",
- headers: {
- "Content-Type": "application/json"
- }
- }).success(function (data) {
- //Byt sida? ändra en bool som aktiverar sidorna som kräver att man är inloggad? jag vet inte?
- });
- }
- }]);
- app.config(function ($routeProvider) {
- $routeProvider.when('/ShowFAQs', {
- templateUrl: 'HtmlTemplates/ShowFAQs.html',
- controller: 'FAQController',
- controllerAs: 'fc'
- })
- .when('/CreateFAQ', {
- templateUrl: 'HtmlTemplates/CreateFAQ.html',
- controller: 'FAQController',
- controllerAs: 'fc'
- })
- .when('/Registration', {
- templateUrl: 'HtmlTemplates/Registration.html',
- controller: 'SignInController',
- controllerAs: 'fc'
- })
- .when('/SignIn', {
- templateUrl: 'HtmlTemplates/SignIn.html',
- controller: 'SignInController',
- controllerAs: 'fc'
- })
- .when('/', {
- templateUrl: 'HtmlTemplates/SignIn.html',
- controller: 'SignInController',
- controllerAs: 'fc'
- })
- .otherwise({
- redirectTo: '/'});
- });
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement