ngTrueValue/ngFalseValue angular 指令

ngTrueValue/ngFalseValue angular directive

我正在学习 angular 教程,我正在自我介绍来自复选框的 ngTrueValue/ngFalseValue angular 指令。

当我这样编码时:

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

Angular 说:

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

我怎么知道 Angular 想告诉我什么?像上面这样的 angular 错误消息的错误消息写在哪里?
事情的套件是上面的例子不起作用
此致

我根据您的代码在 jsfiddle 中创建了一个代码。

  1. 我添加了 ng-controller 指令

  2. 指令 ng-true-value="'claro'" 内部值应该用 ''

  3. 包裹
  4. 因为你使用的是 angularjs 的 minify js (src="lib/angular.min.js") 你可以添加 ng-strict-di 指令,它会让你知道是否有 缺少依赖项注入注释。

  5. 最后是js代码

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

查看我添加的 demo 以查看所有代码。