2

我正在关注一个角度教程,我正在向自己介绍复选框中的 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...

我怎么知道 Angular 想告诉我什么?像上面这样的角度错误消息上的错误消息写在哪里?
问题的工具包是上面的例子不起作用
问候

4

1 回答 1

1

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

  1. 我添加了 ng-controller 指令

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

  3. 由于您使用的是 angularjs (src="lib/angular.min.js") 的 minify js,您可以添加 ng-strict-di 指令,它会让您知道是否缺少任何依赖注入注释。

  4. 最后是js代码

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

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

于 2016-01-23T08:34:16.317 回答