2016-01-23 163 views
2

我正在學習角度教程,並且自我介紹了複選框中的ngTrueValue/ngFalseValue角度指令。

當我如下代碼:ngTrueValue/ngFalseValue角度指令

<body>  
    <p ng-app="app" > 
     <input type="checkbox" ng-model="vm.clarooscuro" ng-true-value="claro" ng-false-value="oscuro"/> 
      Este campo tiene el value modificado. Ahora vale {{ vm.clarooscuro }} 
    </p>   
    <script src="lib/angular.min.js"></script> 
</body> 

角說:

Error: [$injector:modulerr] http://errors.angularjs.org/1.4.8/$injector/modulerr?p0=app&p1=%5B%24injector%3Anomod%5D%20http%3A%2F%2Ferrors.angularjs.org%2F1.4.8%2F%24injector%2Fnomod%3Fp0%3Dapp%0AG%2F%3C%40file%3A%2F%2F%2Fhome%2Fleandro%2FDevelopment%2Fangularjs%2FManualdeAngularJS-Manualcompleto%2Flib%2Fangular.min.js%3A6%3A416%0Ade%2F%3C%2F%3C%2F%3C%40file%3A%2F%2F%2Fhome%2Fleandro%2FDevelopment%2Fangularjs%2FManualdeAngularJS-Manualcompleto%2Flib%2Fangular.min.js%3A24%3A186%0Ab%40file%3A%2F%2F%2Fhome%2Fleandro%2FDevelopment%2Fangularjs%2FManualdeAngularJS-Manualcompleto%2Flib%2Fangular.min.js%3A23%3A251%0Ade%2F%3C%2F%3C%40file%3A%2F%2F%2Fhome%2Fleandro%2FDevelopment%2Fangularjs%2FManualdeAngularJS-Manualcompleto%2Flib%2Fangular.min.js%3A23%3A1%0Ag%2F%3C%40file%3A%2F%2F%2Fhome%2Fleandro%2FDevelopment%2Fangularjs%2FManualdeAngularJS-Manualcompleto%2Flib%2Fangular.min.js%3A38%3A117%0An%40file%3A%2F%2F%2Fhome%2Fleandro%2FDevelopment%2Fangularjs%2FManualdeAngularJS-Manualcompleto%2Flib%2Fangular.min.js%3A7%3A331%0Ag%40file%3A%2F%2F%2Fhome%2Fleandro%2FDevelopment%2Fangularjs%2FManualdeAngularJS-Manualcompleto%2Flib%2Fangular.min.js%3A37%3A488%0Aeb%40file%3A%2F%2F%2Fhome%2Fleandro%2FDevelopment%2Fangularjs%2FManualdeAngularJS-Manualcompleto%2Flib%2Fangular.min.js%3A41%3A249%0Ayc%2Fc%40file%3A%2F%2F%2Fhome%2Fleandro%2FDevelopment%2Fangularjs%2FManualdeAngularJS-Manualcompleto%2Flib%2Fangular.min.js%3A19%3A463%0Ayc%40file%3A%2F%2F%2Fhome%2Fleandro%2FDevelopment%2Fangularjs%2FManualdeAngularJS-Manualcompleto%2Flib%2Fangular.min.js%3A20%3A274%0AZd%40file%3A%2F%2F%2Fhome%2Fleandro%2FDevelopment%2Fangularjs%2FManualdeAngularJS-Manualcompleto%2Flib%2Fangular.min.js%3A19%3A83%0A%40file%3A%2F%2F%2Fhome%2Fleandro%2FDevelopment%2Fangularjs%2FManualdeAngularJS-Manualcompleto%2Flib%2Fangular.min.js%3A294%3A192%0Ab%40file%3A%2F%2F%2Fhome%2Fleandro%2FDevelopment%2Fangularjs%2FManualdeAngularJS-Manualcompleto%2Flib%2Fangular.min.js%3A175%3A62%0AIf%40file%3A%2F%2F%2Fhome%2Fleandro%2FDevelopment%2Fangularjs%2FManualdeAngularJS-Manualcompleto%2Flib%2Fangular.min.js%3A35%3A365%0AHf%2Fd%40file%3A%2F%2F%2Fhome%2Fleandro%2FDevelopment%2Fangularjs%2FManualdeAngularJS-Manualcompleto%2Flib%2Fangular.min.js%3A35%3A314%0A 


...f e?JSON.stringify(e):e;d+=c(e)}return Error(d)}}function za(a){if(null==a||Xa(a... 

我怎麼知道什麼角度想告訴我?在上面的角度錯誤消息中寫入錯誤消息的位置在哪裏?
事情的試劑盒,上面的例子不工作
問候

+0

你有包括你的腳本中包含角模塊的JavaScript嗎? –

+0

看看這個答案http://stackoverflow.com/a/34864059/2485624 –

+0

在開發過程中不要使用縮小版本或角度。使用非縮小版本,您將獲得更好的錯誤消息。但是這裏的錯誤似乎是你沒有定義任何應用程序模塊,儘管你正在使用ng-app =「app」。 –

回答

1

jsfiddle創建了一個基於代碼的代碼。

  1. 我添加了NG-控制器指令

  2. 指令NG-真值= 「 '克拉羅'」 內的值應與 ''

  3. 包裹因爲u的使用縮小js of angularjs(src =「lib/angular.min.js」) 您可以添加ng-strict-di指令,它會讓您知道是否有任何 缺少依賴注入註釋。

  4. 的最後一件事是js代碼

    angular.module('app', []) .controller('myCtrl', function() { var vm = this; vm.clarooscuro = "claro"; })

拿上demo看看我才能看到的所有代碼添加。