I have my main html file structured as follows:
<html ng-app='information'>
<body ng-controller="FirstController as first>
<div ng-controller="SecondController as second>
Following is the custom directive.
<!-- Custom Directive -->
<div id="information">
<myOwnDirective ng-controller="ThirdController as thirdCtrl"></myOwnDirective>
</div>
Directive is created as follows:
(function() {
var app = angular.module('information', ['ui.bootstrap']);
app.directive('myOwnDirective', function(){
return {
restrict: 'E',
templateUrl: 'my-own-directive.html',
};
});
This is my custom directive template:
<uib-accordion tag ng-repeat="info in first">
<form ng-submit="thirdCtrl.updateInformation()">
<div class="form-group">
<label for="someprop">Property</label> <input type="text" name="someprop"
class="form-control" ng-model="info.propValue"
ng-readonly="info.propValue">
</div>
<button type="submit" class="btn btn-success btn-lg btn-block">Click</button>
</form>
And here is my controller where there is the function that is to be invoked on ng-click in custom directive template.
(function() {
angular.module('deviceInfo2').controller('FormController', [ '$scope','$http', function($scope) {
this.updateStatus =function () {
console.log("Inside function");
};
}]);
})();
I want to get data in my custom directive template on ng-click and pass it to the form controller but I cant seem to find way to get the data in there. I have tried exploring creating a service but it is not working. I think I am missing the scope. Can anyone point me in the right direction please. I have been stuck on this for a while and need to make some progress. Thank You.