I have a Jasmine test for my angular controller with the following function:
function compileDirective() {
var body = '<div class="col-sm-4">' +
'<input id="email" type="email" ng-model="form.email" value="[email protected]" field-match="emailsMatch()">' + '</div>';
var tpl = '<form name="myForm">' + body + '</form>';
inject(function($compile) {
var form = $compile(tpl)(scope);
elem = form.find('div');
});
function emailsMatch() {
//do some logic in here, depending on the value of the email field
}
scope.$digest();
}
I want to be able to create another function inside the compileDirective function (emailsMatch()) which looks at the value in the input field and does some logic using it. I don't know how to access the input field though. I have a handle to elem which is the entire html starting with the . How can I look at the value of the input field?