Javascript Angularjs隐藏显示干净编码
嘿,伙计们,我想知道是否有办法解决我通常在角度项目中造成的混乱:Javascript Angularjs隐藏显示干净编码,javascript,angularjs,html,Javascript,Angularjs,Html,嘿,伙计们,我想知道是否有办法解决我通常在角度项目中造成的混乱: app.controller('indexController', function ($scope) { scope.hideWinkelContainer = true; scope.hideWinkelPaneel = true; scope.headerCart = false; scope.showCart = function () { scope.hideWinkelC
app.controller('indexController', function ($scope) {
scope.hideWinkelContainer = true;
scope.hideWinkelPaneel = true;
scope.headerCart = false;
scope.showCart = function () {
scope.hideWinkelContainer = false;
scope.hideWinkelPaneel = false;
};
scope.hideCart = function () {
scope.hideWinkelContainer = true;
scope.hideWinkelPaneel = true;
};
});
html:
欢迎提供最佳实践、提示和示例 您只需使用
切换
功能,如下所示:
app.controller('indexController', function ($scope) {
$scope.hideWinkelContainer = true;
$scope.hideWinkelPaneel = true;
$scope.headerCart = false;
$scope.toggleCart = function () {
$scope.hideWinkelContainer = !$scope.hideWinkelContainer;
$scope.hideWinkelPaneel = !$scope.hideWinkelPaneel;
};
});
在HTML中:
<div class="containerWinkelwagen" ng-hide="hideWinkelContainer">
<div class="winkelWagenPaneel" ng-hide="hideWinkelPaneel">
<div class="winkelWagenTerug" ng-click="toggleCart()"></div>
<div class="winkelWagenTerug" ng-click="toggleCart()"></div>
</div>
</div>
您只需使用
切换功能,如下所示:
app.controller('indexController', function ($scope) {
$scope.hideWinkelContainer = true;
$scope.hideWinkelPaneel = true;
$scope.headerCart = false;
$scope.toggleCart = function () {
$scope.hideWinkelContainer = !$scope.hideWinkelContainer;
$scope.hideWinkelPaneel = !$scope.hideWinkelPaneel;
};
});
在HTML中:
<div class="containerWinkelwagen" ng-hide="hideWinkelContainer">
<div class="winkelWagenPaneel" ng-hide="hideWinkelPaneel">
<div class="winkelWagenTerug" ng-click="toggleCart()"></div>
<div class="winkelWagenTerug" ng-click="toggleCart()"></div>
</div>
</div>
您只需使用切换功能,如下所示:
app.controller('indexController', function ($scope) {
$scope.hideWinkelContainer = true;
$scope.hideWinkelPaneel = true;
$scope.headerCart = false;
$scope.toggleCart = function () {
$scope.hideWinkelContainer = !$scope.hideWinkelContainer;
$scope.hideWinkelPaneel = !$scope.hideWinkelPaneel;
};
});
在HTML中:
<div class="containerWinkelwagen" ng-hide="hideWinkelContainer">
<div class="winkelWagenPaneel" ng-hide="hideWinkelPaneel">
<div class="winkelWagenTerug" ng-click="toggleCart()"></div>
<div class="winkelWagenTerug" ng-click="toggleCart()"></div>
</div>
</div>
您只需使用切换功能,如下所示:
app.controller('indexController', function ($scope) {
$scope.hideWinkelContainer = true;
$scope.hideWinkelPaneel = true;
$scope.headerCart = false;
$scope.toggleCart = function () {
$scope.hideWinkelContainer = !$scope.hideWinkelContainer;
$scope.hideWinkelPaneel = !$scope.hideWinkelPaneel;
};
});
在HTML中:
<div class="containerWinkelwagen" ng-hide="hideWinkelContainer">
<div class="winkelWagenPaneel" ng-hide="hideWinkelPaneel">
<div class="winkelWagenTerug" ng-click="toggleCart()"></div>
<div class="winkelWagenTerug" ng-click="toggleCart()"></div>
</div>
</div>
您可以在工厂实现一次显示/隐藏功能,然后将其注入需要的控制器中。保存了大量样板文件。您可以在工厂实现一次显示/隐藏功能,然后将其注入需要的控制器中。保存了大量样板文件。您可以在工厂实现一次显示/隐藏功能,然后将其注入需要的控制器中。保存了大量样板文件。您可以在工厂实现一次显示/隐藏功能,然后将其注入需要的控制器中。节省了大量的样板文件。你写的东西有什么问题?你在寻找一些优化吗?不要忘记保持它的可维护性(lel角度可维护性)简单!你写的东西有什么问题?你在寻找一些优化吗?不要忘记保持它的可维护性(lel角度可维护性)简单!你写的东西有什么问题?你在寻找一些优化吗?不要忘记保持它的可维护性(lel角度可维护性)简单!你写的东西有什么问题?你在寻找一些优化吗?不要忘记保持它的可维护性(lel角度可维护性)简单!