jeudi 23 juillet 2015

AngularJS Checkbox not changing

I am facing following problem.

I have a controller and a form with some checkboxes. When I click on them, nothing happens.

The HTML looks like this:

<article class="window__Content" ng-controller="ElementController as element">
    <label>Favorite Colors</label>
    <div class="form-group">
        <label class="checkbox-inline">
            <input type="checkbox" name="favoriteColors" ng-model="element.formData.red"> Red
        </label>
        <label class="checkbox-inline">
            <input type="checkbox" name="favoriteColors" ng-model="element.formData.blue"> Blue
        </label>
        <label class="checkbox-inline">
            <input type="checkbox" name="favoriteColors" ng-model="element.formData.green"> Green
        </label>
    </div>
</article>

and my controller looks like this:

(function(){
    'use strict';

    angular
        .module('app')
        .controller('ElementController', [elementController]);

    function elementController(Element, WindowData){

        /* jshint validthis: true */
        var vm = this;
        vm.formData = {
            red: true,
            blue: false,
            green: true
        };

        activate();

        ///////////////

        function activate(){
        }

    }

})();

So all I want to do is to check and uncheck the checkboxes, that would be enough. Maybe anyone of you can spot a mistake.

I should add that the HTML-Snippet is included to the DOM via ng-include. Could this be a problem

Greetz Raj




Aucun commentaire:

Enregistrer un commentaire