SHARE
TWEET

RiboAJAX

a guest Jan 28th, 2016 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Angular application
  2. var ribo = angular.module('ribo', ['ngRoute']);
  3.  
  4. ribo.config(function($routeProvider) {
  5.     $routeProvider
  6.         .when('/',
  7.         {
  8.             controller: "RiboController",
  9.             templateUrl: "input-view.html"
  10.         })
  11.         .when('/output',
  12.         {
  13.             controller: "RiboController",
  14.             templateUrl: "output-view.html"
  15.         })
  16.         .otherwise({ redirectTo: '/'});
  17. });
  18.  
  19. ribo.service('TestService', function($http) {
  20.     this.method1 = function(sequence) {
  21.             console.log(sequence);
  22.             return "Working service " + sequence;
  23.         }
  24.     this.translate = function(sequence) {
  25.         console.log(sequence);
  26.         $http.post('/api/ribo', sequence)
  27.             .success(function(data) {
  28.                 console.log(data);
  29.                 return data;
  30.             })
  31.             .error(function(data) {
  32.                 console.log('Error: ' + data);
  33.             });
  34.        
  35.     };
  36. });
  37.  
  38.  
  39. ribo.controller('RiboController',
  40.     function($scope,$rootScope, $http, $location, TestService) {
  41.         $scope.ntTrans = function(name) {
  42.             $http.post('/api/ribo', $scope.sequence)
  43.                     .success(function(data) {
  44.                         $rootScope.trans = data;
  45.                     })
  46.                     .error(function(data) {
  47.                         console.log('Error: ' + data);
  48.                     });
  49.         };
  50.        
  51.  
  52.        
  53.         // Controller functions ====================
  54.  
  55.         // NEEDS:  service implemented to pass data between views.
  56.         $scope.rollView = function(path) {
  57.             $location.path(path);
  58.         };
  59.  
  60.        
  61.        
  62.         $scope.serviceTest = function() {
  63.             $rootScope.answer = TestService.translate($scope.sequence);
  64.             console.log("controller: " + $rootScope.answer)
  65.         };
  66. });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top