当我点击Not heart
div
时,所有Not heart
div必须隐藏并且所有Hearted
div都会显示。当我点击Hearted
div时,所有Hearted
div必须隐藏,并且所有Not heart
div都会显示。与collection
组件的相同交互。当hearted
DIV显示时,该heartNumber必须增加1,当Not heart
DIV显示时,该heartNumber必须删除1.如何与不同的AngularJS 1.58组件进行交互?
My application architecture is like this:
heart
文件夹是: https://jsfiddle.net/jiexishede/Ltsgnn86/1/
collection
文件夹是: https://jsfiddle.net/jiexishede/hq6dju3c/1/
show
文件夹是: https://jsfiddle.net/jiexishede/e9bxf1f9/1/
在index.html
的代码如下:
<body ng-app="app" ng-controller="controller">
<div style="margin-bottom: 10px">
<heart is-heart="heartBoolean"></heart>
<collection is-collection="collectionBoolean"></collection>
</div>
<div>
<shownumber collection-number="10" heart-number="10"></shownumber>
</div>
<div style="margin-top: 10px">
<heart is-heart="heartBoolean"></heart>
<collection is-collection="collectionBoolean"></collection>
</div>
</body>
<script src="angular.js"></script>
<script src="collection/collectionComponent.js"></script>
<script src="heart/heartComponent.js"></script>
<script src="show/showComponent.js"></script>
<script>
var app = angular.module('app',[]);
app.controller('controller', function ($scope) {
$scope.heartBoolean = true;
$scope.collectionBoolean = true;
})
</script>
<script>
collectionComponentFactoryFun('app','./collection');
showComponentFactoryFun('app','./show');
heartComponentFactoryFun('app','./heart');
</script>
现在,我已经改变了在演示文字。该演示使用名为collectionBoolean的变量和名为heartBoolean的变量。如果更改component
中的布尔状态。我会为您的代码投票,因为您的代码没有耦合。