53 lines
1.9 KiB
JavaScript
53 lines
1.9 KiB
JavaScript
var arr = window.location.href.split("/");
|
|
if (arr[3].indexOf('app') == 0)
|
|
baseUrl = '';
|
|
else
|
|
baseUrl = '/' + arr[3];
|
|
angular.module('CarbonFootprint')
|
|
.config(function ($routeProvider) {
|
|
$routeProvider.when('/Product/Index', {
|
|
templateUrl: baseUrl+'/Partials/Product-Index',
|
|
controller: 'ProductController'
|
|
});
|
|
})
|
|
|
|
.controller('ProductController', [
|
|
'$scope', '$http', '$location', '$timeout',
|
|
function ($scope, $http, $location, $timeout) {
|
|
|
|
// set $scope.baseUrl
|
|
var baseUrl = $scope.baseUrl;
|
|
if (typeof (baseUrl) === 'undefined' || baseUrl == null) {
|
|
var arr = window.location.href.split("/");
|
|
if (arr[3].indexOf('app') == 0)
|
|
baseUrl = '';
|
|
else
|
|
baseUrl = '/' + arr[3];
|
|
$scope.baseUrl = baseUrl;
|
|
}
|
|
|
|
$scope.redirctToCreatePage = function () {
|
|
$location.path('/Product/Create');
|
|
};
|
|
|
|
$scope.redirectToEditPage = function (productId) {
|
|
$location.path('/Product/Edit/' + productId);
|
|
};
|
|
$scope.sortOrder = function (orderBy, orderDir) {//CFT-22 排序
|
|
$http.get($scope.baseUrl+'/api/Product/GetProductsByOrder/' + orderBy + '/' + orderDir)
|
|
.success(function (data, status, headers, config) {
|
|
$scope.productList = data;
|
|
})
|
|
.error(function (data, status) {
|
|
console.log(status);
|
|
});
|
|
};
|
|
$http.get($scope.baseUrl+'/api/Product/GetAll')
|
|
.success(function (data, status, headers, config) {
|
|
$scope.productList = data;
|
|
})
|
|
.error(function (data, status) {
|
|
console.log(status);
|
|
});
|
|
}
|
|
]); |