0
在角材料fullstack约曼发电机采用了棱角分明材料,我结合了toast:方式来处理在控制了大量的外来代码
var last = {
bottom: false,
top: true,
left: false,
right: true
};
$scope.toastPosition = angular.extend({},last);
function sanitizePosition() {
var current = $scope.toastPosition;
if (current.bottom && last.top) current.top = false;
if (current.top && last.bottom) current.bottom = false;
if (current.right && last.left) current.left = false;
if (current.left && last.right) current.right = false;
last = angular.extend({},current);
}
$scope.getToastPosition = function() {
sanitizePosition();
return Object.keys($scope.toastPosition)
.filter(function(pos) { return $scope.toastPosition[pos]; })
.join(' ');
};
var showSimpleToast = function() {
$mdToast.show(
$mdToast.simple()
.content('Please enter a valid stock name.')
.position($scope.getToastPosition())
.hideDelay(3000)
);
};
我能做出来“获取验证码的方式'?它值得实施到服务中吗?我根本不希望它占用我的控制器中的太多空间。
将您的吐司逻辑移至工厂。 – levi
好,无论是为了自己的目的而包装的指令,还是在工厂中拥有逻辑,并从指令或控制器调用以加载烤面包......取决于你将如何使用它以及在哪里......我将它作为指令使用,因为它操纵DOM并从工厂 –
调用添加删除功能,这是一个很有见地的问题。很多可能的答案。 – cgTag