我对Angular JS很新。我有一些产品要显示在我使用ng-repeat显示的主页中。每个产品都有一个'添加到购物车'按钮也使用ng-repeat显示。我的问题是,我想更改我点击的特定按钮的文本。我用过#切换'并且所有按钮文本都在变化。请有人帮我解决这个问题。
我的HTML代码:
<div class="col-md-3 col-sm-6" ng-repeat="item in products">
<div class="thumbnail">
<image src="{{item.imageUrl}}"></image>
</div>
<div>
<button class="btn btn-primary" ng-click="toggle(item)">{{buttonText}}</button>
</div>
</div>
我的角度js代码:
var toggle = false;
$scope.toggle = function(item){
$scope.buttonText = toggle ? 'Add To Cart' : 'Remove From Cart';
toggle=!toggle;
}
答案 0 :(得分:3)
您需要向要传递的项目添加属性。然后使用该属性。更改范围将改变所有实例。
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
account-plugin-windows-live libapparmor-perl libmbim-glib0 libqmi-glib0
libupstart1 python-colorama python-colorama-whl python-distlib
python-distlib-whl python-html5lib python-html5lib-whl python-setuptools-whl
python-six-whl python-wheel usb-modeswitch usb-modeswitch-data
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
cpp-4.8 g++-4.8 gcc-4.8 gcc-4.8-base lib32gcc1 lib32tinfo5 libasan0
libatomic1 libc6-i386 libgcc-4.8-dev libgfortran3 libgomp1 libitm1
libquadmath0 libstdc++-4.8-dev libstdc++6 libtsan0
Suggested packages:
gcc-4.8-locales g++-4.8-multilib gcc-4.8-doc libstdc++6-4.8-dbg
gcc-4.8-multilib libgcc1-dbg libgomp1-dbg libitm1-dbg libatomic1-dbg
libasan0-dbg libtsan0-dbg libquadmath0-dbg libstdc++-4.8-doc
The following NEW packages will be installed:
lib32bz2-1.0 lib32gcc1 lib32ncurses5 lib32stdc++6 lib32tinfo5 lib32z1
libc6-i386
The following packages will be upgraded:
cpp-4.8 g++-4.8 gcc-4.8 gcc-4.8-base libasan0 libatomic1 libgcc-4.8-dev
libgfortran3 libgomp1 libitm1 libquadmath0 libstdc++-4.8-dev libstdc++6
libtsan0
14 upgraded, 7 newly installed, 0 to remove and 277 not upgraded.
Need to get 33,9 MB/34,2 MB of archives.
After this operation, 15,4 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Err http://tr.archive.ubuntu.com/ubuntu/ trusty-updates/main libitm1 amd64 4.8.4-2ubuntu1~14.04.1
404 Not Found [IP: 193.140.100.100 80]
Err http://tr.archive.ubuntu.com/ubuntu/ trusty-updates/main libgomp1 amd64 4.8.4-2ubuntu1~14.04.1
404 Not Found [IP: 193.140.100.100 80]
Err http://tr.archive.ubuntu.com/ubuntu/ trusty-updates/main libquadmath0 amd64 4.8.4-2ubuntu1~14.04.1
404 Not Found [IP: 193.140.100.100 80]
Err http://tr.archive.ubuntu.com/ubuntu/ trusty-updates/main libgfortran3 amd64 4.8.4-2ubuntu1~14.04.1
404 Not Found [IP: 193.140.100.100 80]
Err http://tr.archive.ubuntu.com/ubuntu/ trusty-updates/main libasan0 amd64 4.8.4-2ubuntu1~14.04.1
404 Not Found [IP: 193.140.100.100 80]
Err http://tr.archive.ubuntu.com/ubuntu/ trusty-updates/main libatomic1 amd64 4.8.4-2ubuntu1~14.04.1
404 Not Found [IP: 193.140.100.100 80]
Err http://tr.archive.ubuntu.com/ubuntu/ trusty-updates/main libtsan0 amd64 4.8.4-2ubuntu1~14.04.1
404 Not Found [IP: 193.140.100.100 80]
Err http://tr.archive.ubuntu.com/ubuntu/ trusty-updates/main g++-4.8 amd64 4.8.4-2ubuntu1~14.04.1
404 Not Found [IP: 193.140.100.100 80]
Err http://tr.archive.ubuntu.com/ubuntu/ trusty-updates/main gcc-4.8 amd64 4.8.4-2ubuntu1~14.04.1
404 Not Found [IP: 193.140.100.100 80]
Err http://tr.archive.ubuntu.com/ubuntu/ trusty-updates/main cpp-4.8 amd64 4.8.4-2ubuntu1~14.04.1
404 Not Found [IP: 193.140.100.100 80]
Err http://tr.archive.ubuntu.com/ubuntu/ trusty-updates/main libstdc++-4.8-dev amd64 4.8.4-2ubuntu1~14.04.1
404 Not Found [IP: 193.140.100.100 80]
Err http://tr.archive.ubuntu.com/ubuntu/ trusty-updates/main libgcc-4.8-dev amd64 4.8.4-2ubuntu1~14.04.1
404 Not Found [IP: 193.140.100.100 80]
Err http://tr.archive.ubuntu.com/ubuntu/ trusty-updates/main gcc-4.8-base amd64 4.8.4-2ubuntu1~14.04.1
404 Not Found [IP: 193.140.100.100 80]
Err http://tr.archive.ubuntu.com/ubuntu/ trusty-updates/main libstdc++6 amd64 4.8.4-2ubuntu1~14.04.1
404 Not Found [IP: 193.140.100.100 80]
Err http://tr.archive.ubuntu.com/ubuntu/ trusty-updates/main libc6-i386 amd64 2.19-0ubuntu6.7
404 Not Found [IP: 193.140.100.100 80]
Err http://tr.archive.ubuntu.com/ubuntu/ trusty-updates/main lib32stdc++6 amd64 4.8.4-2ubuntu1~14.04.1
404 Not Found [IP: 193.140.100.100 80]
Err http://security.ubuntu.com/ubuntu/ trusty-security/main libc6-i386 amd64 2.19-0ubuntu6.7
404 Not Found [IP: 91.189.88.161 80]
E: Failed to fetch http://tr.archive.ubuntu.com/ubuntu/pool/main/g/gcc-4.8/libitm1_4.8.4-2ubuntu1~14.04.1_amd64.deb 404 Not Found [IP: 193.140.100.100 80]
E: Failed to fetch http://tr.archive.ubuntu.com/ubuntu/pool/main/g/gcc-4.8/libgomp1_4.8.4-2ubuntu1~14.04.1_amd64.deb 404 Not Found [IP: 193.140.100.100 80]
E: Failed to fetch http://tr.archive.ubuntu.com/ubuntu/pool/main/g/gcc-4.8/libquadmath0_4.8.4-2ubuntu1~14.04.1_amd64.deb 404 Not Found [IP: 193.140.100.100 80]
E: Failed to fetch http://tr.archive.ubuntu.com/ubuntu/pool/main/g/gcc-4.8/libgfortran3_4.8.4-2ubuntu1~14.04.1_amd64.deb 404 Not Found [IP: 193.140.100.100 80]
E: Failed to fetch http://tr.archive.ubuntu.com/ubuntu/pool/main/g/gcc-4.8/libasan0_4.8.4-2ubuntu1~14.04.1_amd64.deb 404 Not Found [IP: 193.140.100.100 80]
E: Failed to fetch http://tr.archive.ubuntu.com/ubuntu/pool/main/g/gcc-4.8/libatomic1_4.8.4-2ubuntu1~14.04.1_amd64.deb 404 Not Found [IP: 193.140.100.100 80]
E: Failed to fetch http://tr.archive.ubuntu.com/ubuntu/pool/main/g/gcc-4.8/libtsan0_4.8.4-2ubuntu1~14.04.1_amd64.deb 404 Not Found [IP: 193.140.100.100 80]
E: Failed to fetch http://tr.archive.ubuntu.com/ubuntu/pool/main/g/gcc-4.8/g++-4.8_4.8.4-2ubuntu1~14.04.1_amd64.deb 404 Not Found [IP: 193.140.100.100 80]
E: Failed to fetch http://tr.archive.ubuntu.com/ubuntu/pool/main/g/gcc-4.8/gcc-4.8_4.8.4-2ubuntu1~14.04.1_amd64.deb 404 Not Found [IP: 193.140.100.100 80]
E: Failed to fetch http://tr.archive.ubuntu.com/ubuntu/pool/main/g/gcc-4.8/cpp-4.8_4.8.4-2ubuntu1~14.04.1_amd64.deb 404 Not Found [IP: 193.140.100.100 80]
E: Failed to fetch http://tr.archive.ubuntu.com/ubuntu/pool/main/g/gcc-4.8/libstdc++-4.8-dev_4.8.4-2ubuntu1~14.04.1_amd64.deb 404 Not Found [IP: 193.140.100.100 80]
E: Failed to fetch http://tr.archive.ubuntu.com/ubuntu/pool/main/g/gcc-4.8/libgcc-4.8-dev_4.8.4-2ubuntu1~14.04.1_amd64.deb 404 Not Found [IP: 193.140.100.100 80]
E: Failed to fetch http://tr.archive.ubuntu.com/ubuntu/pool/main/g/gcc-4.8/gcc-4.8-base_4.8.4-2ubuntu1~14.04.1_amd64.deb 404 Not Found [IP: 193.140.100.100 80]
E: Failed to fetch http://tr.archive.ubuntu.com/ubuntu/pool/main/g/gcc-4.8/libstdc++6_4.8.4-2ubuntu1~14.04.1_amd64.deb 404 Not Found [IP: 193.140.100.100 80]
E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/e/eglibc/libc6-i386_2.19-0ubuntu6.7_amd64.deb 404 Not Found [IP: 91.189.88.161 80]
E: Failed to fetch http://tr.archive.ubuntu.com/ubuntu/pool/main/g/gcc-4.8/lib32stdc++6_4.8.4-2ubuntu1~14.04.1_amd64.deb 404 Not Found [IP: 193.140.100.100 80]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
有点像上面