2017-01-12 26 views
0

AngularJSに慣れ、現在タグ内のコードに問題がある簡単なプログラムです。私はこのコードを、中括弧、常にWebページに表示される内部のコンテンツを実行するたびに、どのように私はウェブページに中括弧が表示されないようにする

<head> 
    <title> Your Shopping Cart </title> 
</head> 

<body ng-controller="CartController"> 
<h1> Your Order </h1> 

<div ng-repeat="item in items"> 

<input ng-model="item.quantity"> 
    *<span>{{item.title}}</span> //Keeps showing on webpage 
    <span>{{item.price | currency}}</span> //Keeps showing on webpage 
    <span>{{item.price * item.quantity | currency}}</span>* //Keeps showing on webpage 
<button ng-click="remove($index)">Remove</button> 

</div> 

<script src="angular.min.js"> </script> 

<script> 
function CartController($scope) {$scope.items = [ 

    {title: 'Paint Pots', quantity: 8, price: 3.95}, 
    {title: 'Polka Dots', quantity: 17, price: 12.95}, 
    {title: 'Pebbles', quantity: 5, price: 6.95} 
    ]; 

    scope.remove = function(index){$scope.items.splice(iindex, 1); 
    } 
} 
</script> 

</body> 

+0

コンパイルエラーのためのソール。構文エラーのためAngularがクラッシュする可能性があります。 – georgeawg

答えて

0

使用NGバインドまたはNG-マントを起こってからそれを防ぎますか:

ng-bindhttps://docs.angularjs.org/api/ng/directive/ngBind

*<span ng-bind="item.title"></span> 
<span ng-bind="item.price | currency"></span> 
<span ng-bind="item.price * item.quantity | currency"></span>* 

ng-cloakng-bindhttps://docs.angularjs.org/api/ng/directive/ngCloak

<div ng-repeat="item in items" ng-cloak> 
    <input ng-model="item.quantity"> 
    *<span>{{item.title}}</span> //Keeps showing on webpage 
    <span>{{item.price | currency}}</span> //Keeps showing on webpage 
    <span>{{item.price * item.quantity | currency}}</span>* //Keeps showing on webpage 
    <button ng-click="remove($index)">Remove</button> 
</div> 

ワーキングフィドル実装:http://jsfiddle.net/ADukg/9154/

+0

私はng-bindを使用しましたが、私は教科書と見出しだけを見ています。他に何も表示されていません – Robbie

+0

@Robbie - フィドルをチェックしてください。正常に動作しています。エラーがあればブラウザの開発者コンソールも確認してください – Aks1357

0
はheadタグやbodyタグ

<head> 
    <title> Your Shopping Cart </title> 
<script src="angular.min.js"> </script> 
</head> 

または

<body> 
<script src="angular.min.js"> </script> 
のトップにあなたの角度ライブラリリファレンスを移動

関連する問題