Is there a way to ensure that one of the input fields is not empty and that the #urlink follows the format of a URL before executing this function in JavaScript?
$scope.favUrls.$add
I'm uncertain about how to approach this.
html
<input type="text" id="urlName" class="form-control" placeholder="" ng-model="mvName" />
<input type="text" id="urlLink" class="form-control" placeholder="" ng-model="mvUrl" />
app.js
$scope.saveToList = function(event) {
var mvName = $scope.mvName.trim();
var mvUrl = $scope.mvUrl.trim();
if (mvName.length > 0) {
$scope.favUrls.$add({
name: mvName,
title: mvUrl
});
urlName.value = ''; //urlName is the ID of input box - Angular rocks!
urlLink.value = ''; //urlName is the ID of input box - Angular rocks!
}
}