sum7/warehost-frontend
sum7
/
warehost-frontend
Archived
1
0
Fork 0
This repository has been archived on 2020-09-27. You can view files and clone it, but cannot push or open issues or pull requests.
warehost-frontend/public/app/web/menu.js

31 lines
862 B
JavaScript

'use strict';
angular.module('warehost')
.controller('MenuWebCtrl',function(session,config,alert,$scope,$rootScope,$http,$stateParams){
alert.set({});
$scope.list = {};
$scope.website = {};
function load(){
$http.get(config.api+'/web/involve').then(function(res){
session.set(res);
alert.set(res);
$scope.list = res.data.data;
for(var key in res.data.data){
var item = res.data.data[key];
if(item.website.ID+'' === $stateParams.websiteid){
$scope.website = item.website;
}
}
});
}
load();
$rootScope.$on('warehost.session',load);
$rootScope.$on('warehost.web.website.update',load);
$scope.add = function(){
$http.post(config.api+'/web/website',{name:window.prompt('Name:')}).then(function(res){
session.set(res);
$rootScope.$broadcast('warehost.web.website.update');
});
};
});