私はAngularの初心者で、すべてのチュートリアルを読みましたが、実際のアプリケーションを初めて構築する学習曲線の急なポイントにいます.
特定のラジオボタンがクリックされた場合にのみ div を表示したい。
これは私のコードです:
// HTML file
<label class="checkbox-inline">
<input type="radio" name="ast-adh-p1-radio" ng-model="value" ng-change='answerP1(value)' value="yes"> Yes
</label>
<label class="checkbox-inline">
<input type="radio" name="ast-adh-p1-radio" ng-model="value" ng-change='answerP1(value)' value="no"> No
</label>
<div ng-show="showQ1A">hello world </div>
// Controller file
angular
.module('adh.controllers', ['ngModel'])
.controller('adhCtrl', ['$scope', function ($scope) {
$scope.answerP1 = function(value) {
console.log('clicked radio button', value);
// change $scope.showQ1A accordingly
}
}]);
残念ながら、次のエラーが表示され、Google で解決できません。
Uncaught Error: [$injector:modulerr] Failed to instantiate module myApp due to:
Error: [$injector:modulerr] Failed to instantiate module adh.controllers
due to:
Error: [$injector:modulerr] Failed to instantiate module ngModel due to:
Error: [$injector:nomod] Module 'ngModel' is not available! You either misspelled
the module name or forgot to load it. If registering a module ensure that you
specify the dependencies as the second argument.
を使用するために外部ファイルをロードする必要がありますngModel
か? これはドキュメントに記載されていません。
もしそうなら、物事を行うためのより簡単な方法はありますか?