在javascript中使用angularjs的数据绑定的正确方法是什么?
我没有找到任何关于如何实现这一点的方法,所以我来这里是想问一下。 我有这个在javascript中使用angularjs的数据绑定的正确方法是什么?,javascript,angularjs,Javascript,Angularjs,我没有找到任何关于如何实现这一点的方法,所以我来这里是想问一下。 我有这个 if document.documentElement.clientWidth < document.documentElement.clientHeight document.getElementById('{{product.id}}').src = 'http://www.placehold.it/500x500?text={{product.id}}' else document.g
if document.documentElement.clientWidth < document.documentElement.clientHeight
document.getElementById('{{product.id}}').src = 'http://www.placehold.it/500x500?text={{product.id}}'
else
document.getElementById('{{product.id}}').src = 'http://www.placehold.it/809x500?text={{product.id}}'
这完全是错误的做法。在HTML模板中使用ng if,而不是document.getElementById。@Claies噢,谢谢你,现在这更有意义了。我很抱歉问了一些愚蠢的问题,但我还在学习,我不知道每一条指令。在学习时请记住这一点…很少需要自己操作dom。花几分钟时间浏览api中的各种核心指令。是时候了spent@charlietfl会办好的,谢谢@质询为什么我在imgalt={{product.product}}中只得到false,ng src={{document.documentElement.clientWidth
a(ng-href='#!/products/{{product.id}}')
img(alt='{{product.product}}', id='{{product.id}}')