I have a plunk at http://plnkr.co/PF7cRQE4n5lYube8oa3t
The templateUrl points to control.html with the following code.
hello from Directive
<br />{{message}}
<br />
<input type="checkbox" {{checkedstatus}} />
<br />Value of Checked Status = {{checkedstatus}}
My controller and directive is as follows...
var app = angular.module('plunker', []);
app.controller('MainCtrl', function($scope) {
$scope.name = 'World';
})
.directive('myDir', function() {
var linkFunction = function(scope, element, attributes){
scope.message = "The check box should be checked... no?";
scope.checkedstatus = "checked";
}
return {
restrict: 'E',
templateUrl: "control.html",
link: linkFunction,
scope: {}
};
})
My index.html file is straight forward and is using the directive...
<my-dir></my-dir>
I was assuming that if checkedstatus is set to "checked" I will see the checkbox as checked in the UI. But it doesn't happen that way and remains unchecked. My goal is to use this Checkbox as a toggle button to view or hide certain elements of my view.