SHARE
TWEET
RiboAJAX
a guest
Jan 28th, 2016
63
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- // Angular application
- var ribo = angular.module('ribo', ['ngRoute']);
- ribo.config(function($routeProvider) {
- $routeProvider
- .when('/',
- {
- controller: "RiboController",
- templateUrl: "input-view.html"
- })
- .when('/output',
- {
- controller: "RiboController",
- templateUrl: "output-view.html"
- })
- .otherwise({ redirectTo: '/'});
- });
- ribo.service('TestService', function($http) {
- this.method1 = function(sequence) {
- console.log(sequence);
- return "Working service " + sequence;
- }
- this.translate = function(sequence) {
- console.log(sequence);
- $http.post('/api/ribo', sequence)
- .success(function(data) {
- console.log(data);
- return data;
- })
- .error(function(data) {
- console.log('Error: ' + data);
- });
- };
- });
- ribo.controller('RiboController',
- function($scope,$rootScope, $http, $location, TestService) {
- $scope.ntTrans = function(name) {
- $http.post('/api/ribo', $scope.sequence)
- .success(function(data) {
- $rootScope.trans = data;
- })
- .error(function(data) {
- console.log('Error: ' + data);
- });
- };
- // Controller functions ====================
- // NEEDS: service implemented to pass data between views.
- $scope.rollView = function(path) {
- $location.path(path);
- };
- $scope.serviceTest = function() {
- $rootScope.answer = TestService.translate($scope.sequence);
- console.log("controller: " + $rootScope.answer)
- };
- });
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.
