I would like to check if one of the input fields is empty and if the #urlink is a the format of a URL before I perform this function in the js:
$scope.favUrls.$add
not sure how to go about it.
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!
}
}