github.com/fanux/shipyard@v0.0.0-20161009071005-6515ce223235/controller/static/app/strategies/sinspect.controller.js (about) 1 (function(){ 2 'use strict'; 3 4 angular 5 .module('shipyard.plugins') 6 .controller('StrategyController', StrategyController); 7 8 StrategyController.$inject = ['resolvedStrategy', 'StrategyService', '$state']; 9 function StrategyController(resolvedStrategy, StrategyService, $state) { 10 var vm = this; 11 vm.strategy = resolvedStrategy; 12 vm.StrategyStatusText = StrategyStatusText; 13 vm.jsonDocument=jsonDocument; 14 } 15 16 function jsonDocument(obj){ 17 try { 18 var res= new Function("return " + obj + ";")(); 19 } catch (e) { 20 var res={"error": "类型异常,请修改!!!"}; 21 } 22 var out = JSON.stringify(res, null, 4); 23 return out; 24 } 25 function StrategyStatusText(strategy) { 26 if(strategy.Status.indexOf("enable")==0){ 27 if (strategy.Status.indexOf("(disable)") != -1) { 28 return "disable"; 29 } 30 return "enable"; 31 } 32 } 33 })();