如何在父级中访问模板控件值。 [英] How to access a template control value in parent.
本文介绍了如何在父级中访问模板控件值。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们有控制器,它有ng-include来加载外部html。现在我想访问父母的控制值。
我的模板是MainMenuCreate
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
@{
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);
});
}
});
当我调用此保存方法然后$ scope.MainMenuId显示未定义的
when i call this save method then $scope.MainMenuId shows undefined
推荐答案
范围,MainMenuService){
scope, MainMenuService) {
scope.Save = function(){
var MainMenuRecord =
{
MainMenuId:
scope.Save = function () { var MainMenuRecord = { MainMenuId:
scope.MainMenuId,
MainMenu:
scope.MainMenuId, MainMenu:
这篇关于如何在父级中访问模板控件值。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文