Click here to Skip to main content
15,905,322 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
we have controller which has ng-include to load an external html. now i want to access a control value in parent.

my template is MainMenuCreate
XML
@{

    Layout = null;
}
<div >
<h2>{{Headtitle}}</h2>
<p>
    <div style="width:200px;">MainMenuId :</div>
     <input type="text" name="MainMenuId" id="MainMenuId" data-ng-model="MainMenuId" />
</p>
<p>
    <div style="width:200px;">MainMenu :</div>
     <input type="text" name="MainMenu" id="MainMenu" data-ng-model="MainMenu" />
</p>
<p>
    <div style="width:200px;">PageTitle :</div>
     <input type="text" name="PageTitle" id="PageTitle" data-ng-model="PageTitle" />
</p>

 <input type="button" name="btnSave" id="btnSave" value="Save" ng-click="Save()" />



and my main page is
<div data-ng-app="MainMenuModule">
    <div data-ng-controller="MainMenuController">
    <div data-ng-include="'MainMenuCreate'" >
     </div>
      {{MainMenuId}}
    </div>
        
</div>


and controller is

app.controller('MainMenuController', function ($scope, MainMenuService) {
   

    $scope.Save = function () {
        
        var MainMenuRecord =
            {
                MainMenuId: $scope.MainMenuId,
                MainMenu: $scope.MainMenu,
                PageTitle: $scope.PageTitle,
               pe.HomePanelStatus,
                PageId: $scope.PageId
            };
        var promisePost = MainMenuService.post(MainMenuRecord);
        promisePost.then(function (pl) {
            $scope.MainMenu = pl.data.MainMenu;
            loadRecords();
        }, function (err) {
            console.log("Err" + err);
        });
    }

});


when i call this save method then $scope.MainMenuId shows undefined
Posted
Updated 23-Jun-15 18:48pm
v3

1 solution

Please provide more clarification on this as the title and the initial phrases are contradictory.

"how to get child directive from parent"
Or
"now i want to access a control value in parent."?
 
Share this answer
 
Comments
maneesh katiyar 24-Jun-15 0:33am    
i want to access a control value in parent.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900