HTML
<div class="form-group"><label class="col-md-4 control-label" for="s1">URL</label>
<div class="col-md-4"><input id="url" name="url" type="text" ng-change="checkVal()" ng-model="url" placeholder="" class="form-control input-md"></div>
</div>
Javascript v1.6
var app = angular.module('urlGeneratorAvid', [])
.controller('macroControllerAvid',['$scope', function ($scope) {
$scope.needQuestionMark = true;
$scope.url = '';
$scope.checkVal = function() {
console.log("Checking Value.");
if ($scope.url.includes('?')) {
console.log("Detected!");
$scope.needQuestionMark = false;
console.log("Question Mark Variable: " + $scope.needQuestionMark);
} else {
$scope.needQuestionMark = true;
console.log("Question Mark Variable: " + $scope.needQuestionMark);
}
}
}]);
The Objective
I am struggling to alter the variable needQuestionMark from the directive even though it displays correct data.
Main Aim
To identify if the URL input already has a question mark in order to prevent duplication and use an ampersand instead.
New to AngularJS, seeking guidance on the right path. Thank you!