I'm new to angular and using a function to load data using $http, that worked for me. After that I decided to do some form validation to see it's behaviour. I can do it individually but a bit confused on how can I merge my code with the above so that both of my functions work well. The code is as:
var App = angular.module('App', []);
App.controller('DataCtrl', function($scope, $http) {
$http.get('any url or file')
.then(function(result) {
$scope.data = result.data;
});
});
The controller is defined in the body attribute like this:
<body ng-controller="DataCtrl">
Now when I put the other function in the same app.js file, it doesn't work, can anybody help me out on this, the validation code is something like this:
App.controller('DataCtrl', function($scope) {
$scope.submitForm = function(isValid) {
if (isValid) {
alert('submitting data');
}
};
});
The only thing I need to do this is to make them work like this: 1. Load data (working) 2. Implement validation with the help of second code block.