Angularjs 很难回复我的全名-回复不满足
这就是我尝试返回全名的方式,但它给了我这个 在主I angularjs 1.5.x文件中,我从他们的CDN中获取代码 问题是,当我在节目中写下(如名字和姓氏)这么厚的内容时,我什么也没写,所以它也显示了我在下面写的内容Angularjs 很难回复我的全名-回复不满足,angularjs,model-view-controller,view,Angularjs,Model View Controller,View,这就是我尝试返回全名的方式,但它给了我这个 在主I angularjs 1.5.x文件中,我从他们的CDN中获取代码 问题是,当我在节目中写下(如名字和姓氏)这么厚的内容时,我什么也没写,所以它也显示了我在下面写的内容 {{fullName()}} 我还尝试标记()并再次添加它们,但仍然像我在这里写的那样显示它们 Create.cshtml文件: <div class="col-lg-6" ng-app="UserValue" ng-controller="UserFirstValue
{{fullName()}}
我还尝试标记()并再次添加它们,但仍然像我在这里写的那样显示它们
Create.cshtml文件:
<div class="col-lg-6" ng-app="UserValue" ng-controller="UserFirstValue">
@using (Html.BeginForm(HelperSettingsClass.HelperSettings.AccountCreate, HelperSettingsClass.HelperSettings.AccountMappe, FormMethod.Post, new
{
@class = "form-horizontal"
}))
{
<div class="form-group">
<div class="col-xs-12">
@Html.LabelFor(u => u.Fornavn)
@Html.TextBoxFor(u => u.Fornavn, new
{
@class = "form-control",
@id = "Firstname",
@ng_model = "FirstnameApp",
@placeholder = HelperTextClass.HelperText.placeholderInfo.Fornavn,
@required = ""
})
@Html.ValidationMessageFor(u => u.Fornavn, "", new
{
@class = "label label-danger"
})
</div>
</div>
<div class="form-group">
<div class="col-xs-12">
@Html.LabelFor(u => u.Efternavn)
@Html.TextBoxFor(u => u.Efternavn, new
{
@class = "form-control",
@id = "Lastname",
@ng_model = "LastnameApp",
@placeholder = HelperTextClass.HelperText.placeholderInfo.Efternavn,
@required = ""
})
@Html.ValidationMessageFor(u => u.Efternavn, "", new
{
@class = "label label-danger"
})
</div>
</div>
<div class="form-group">
<div class="col-xs-12">
<p class="label label-danger"></p>
<button type="submit" class="btn btn-success" id="clickUserCreate"><i class="fa fa-plus"></i> {{fullName()}}</button>
</div>
</div>
}
</div>
控制器的逻辑仅在初始化时运行,因此不会创建函数,因为这些变量还没有值 因此,你可以这样做:
$scope.fullName = function () {
if ($scope.FirstnameApp != null && $scope.LastnameApp != null)
return "Velkommen" + $scope.FirstnameApp + " " + $scope.LastnameApp;
else
return "Opret bruger";
};
<div ng-show="firstName && lastName">
Welcome, {{name}} {{lastName}}
</div>
<div ng-hide="firstName && lastName">
No name
</div>
注:
我觉得用函数来做这个有点难看。它违反了一般的AngularJS风格准则,因为您正在控制器中放置视图关注点。这样做会更好:
$scope.fullName = function () {
if ($scope.FirstnameApp != null && $scope.LastnameApp != null)
return "Velkommen" + $scope.FirstnameApp + " " + $scope.LastnameApp;
else
return "Opret bruger";
};
<div ng-show="firstName && lastName">
Welcome, {{name}} {{lastName}}
</div>
<div ng-hide="firstName && lastName">
No name
</div>
欢迎,{{name}{{lastName}}
没有名字
这无助于客户继续合作:(这是AngularJs文件中的make error,你可以在这里看到:AngularJs错误消息非常棒。它们以stacktraces的形式显示,并包含指向问题详细描述的文档的可单击链接。使用它。它告诉我:将错误编辑到你的问题中,而不是png,并用从中生成的实际html替换html模板。)我知道。