I have the following angular directive:
app.directive("partnersInfoView", function ($http) {
return {
restrict: 'A',
link: function ($scope, element) {
$http.get("/home/PartnerInfoTab")
.success(function (data) {
element.html(data);
});
}
};
});
which basically goes to the MVC controller and returns a partial view
public ActionResult PartnerInfoTab()
{
return PartialView("../ManagePartners/PartnerInfoTab");
}
in the parent view, I have the following declaration:
<div id="genericController" ng-controller="GenericController">
<div partners-info-view></div>
</div>
which uses the angular directive to partially view, so far everything is working fine. Inside my angular genericController, I have a scope variable:
$scope.Data = data;
where data is a json object that comes as a response from the Rest service
Json Response e.g.
{[
{"firstName":"John", "lastName":"Doe"},
{"firstName":"Anna", "lastName":"Smith"},
{"firstName":"Peter", "lastName":"Jones"}
]}
The problem im is that I cannot bind the variable $ scope.Data in the directive template:
<div id="PartnerInfoTab">
<div class="form-group">
<label class="col-md-2 control-label">Name</label>
<div class="col-md-8">
<input id="txt_name" class="form-control" type="text" ng-model="Data.firstName">
</div>
</div>
</div>
My question is: how do I pass the parent scope to the angular directive in order to be able to bind data to elements in a partial view. What am I missing?
Thanks in advance.