[英]cant get angular to initiate
我正在使用plnkr編寫我正在使用的角度應用程序的代碼,但是當我嘗試在本地對其進行編碼時,所有角度似乎都停止響應。
這是我的html:我嘗試使用angulars CDN並鏈接實際文件,但沒有任何效果。
<!DOCTYPE html>
<html ng-app='store'>
<head>
<meta charset="utf-8">
<script src="angular.min.js"></script>
</head>
<body>
<div ng-controller="StoreController as store">
<div ng-hide="store.product.soldOut">
<h1> {{store.product.name}}</h1>
<h2> ${{store.product.price}}</h2>
<p> {{store.product.description}}</p>
<input type="text" ng-model="yourName" placeholder="enter name">
hello, {{yourName}}
<button ng-show="store.product.canPurchase"> add to cart</button>
</div>
</div>
<script src="app.js"></script>
</body>
</html>
(function() { // code via app.js
var app = angular.module('store', []);
app.controller('StoreController', function() {
this.product = gem;
});
var gem = {
name: 'Dodecahedron',
price: 2.95,
description: '. . .',
canPurchase: true,
soldOut:true,
};
})();
確保您對角度庫資源的調用正常工作-或路徑正確。 在開發者控制台中仔細檢查。 以下是通過Google CDN實現的版本和簡單的實現-也請查看“使用角度啟動啟動應用程序”,它很有用! 如果您的控制台有錯誤,請更新您的問題!
CDN上的angular js: <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"></script>
<!doctype html><!-- sample only -->
<html ng-app>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"></script>
</head>
<body>
<div>
<input type="text" ng-model="yourName" placeholder="Enter a name here">
<h1>Hello, {{ yourName }}!</h1>
</div>
</body>
</html>
很好的教程 。 <-閱讀
同樣,這可能只是在在線IDE中啟動時遇到的問題。 有一個引導到內使用的jsfiddle .NET所以你可能要檢查出的規則或指導與plnkr做啟動。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.