2015-06-24 29 views
0

我正在使用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, 
    }; 

})(); 
+2

你在哪裏加載角度js庫? –

+0

您是否檢查過您正在使用的瀏覽器的網絡標籤並驗證JS文件是否正在加載? – CuriousMind

+0

@COOOL它在我的JS文件夾中。 –

回答

0

確保您的角度圖書館資源調用工作 - 或路徑是正確的。仔細檢查您的開發者控制檯。下面是一個通過谷歌CDN和簡單的實施版本 - 也檢查了「角度tut啓動你的應用程序」它是有用的!如果您的控制檯出現錯誤,請更新您的問題!上CDN

角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> 

良好tutorial。 < - 閱讀


此外,這可能只是您的在線IDE中啓動的問題。有一個guide啓動內使用JSfiddle .net所以你可能想看看規則或指導與plnkr做。

+0

@cool它的奇怪,我補充說cdn到我的索引,它仍然沒有工作。但是,當我將該代碼複製到我的索引只有它的工作。 –

+0

那麼你的代碼有問題 - 可能在那裏結束。 –

+0

事情是它在plnkr上工作,但是當我在本地文件上使用相同的代碼時,它不起作用 –