บทช่วยสอนนี้แสดงให้เห็นถึงการใช้คำสั่งngSrc
แทนsrc
:
<ul class="phones">
<li ng-repeat="phone in phones" class="thumbnail">
<img ng-src="{{phone.imageUrl}}">
</li>
</ul>
พวกเขาขอให้:
แทนที่คำสั่ง ng-src ด้วยแอตทริบิวต์ src เก่าธรรมดา
การใช้เครื่องมือเช่น Firebug หรือ Web Inspector ของ Chrome หรือการตรวจสอบบันทึกการเข้าถึงเว็บเซิร์ฟเวอร์ยืนยันว่าแอปส่งคำขอโดยไม่เกี่ยวข้องไปยัง/app/%7B%7Bphone.imageUrl%7D%7D (หรือ / app / {{phone) .imageUrl}} )
ฉันทำเช่นนั้นและให้ผลลัพธ์ที่ถูกต้อง:
<li class="thumbnail ng-scope" ng-repeat="phone in phones">
<img src="img/phones/motorola-xoom.0.jpg">
</li>
มีเหตุผลว่าทำไม?