AngularJS UI-Router编辑页面标题

时间:2018-04-25 11:03:17

标签: angularjs angular-ui-router

我正在使用symfony 2.8后台处理AngularJs应用程序。我想编辑联系页面标题。这是联系页面的代码:

<div ng-controller="contactFormCtrl">
<fieldset>
    <h1 translate="front.CONTACT">Contact</h1>
    <h2 ng-bind-html="post.content"></h2>
    <form  name="contactForm" id="contactForm" class="form" data-ng-submit="submitForm(contactForm)">
        <div class="form-group" ng-class="{'has-error':contactForm.firstName.$dirty && contactForm.firstName.$invalid, 'has-success':contactForm.firstName.$valid}">
            <label for="contactFirstName" class="control-label">
                <span translate="content.list.fields.FIRSTNAME">First Name</span>
                <span class="symbol required"></span>
            </label>
            <span class="input-icon">
                <input name="firstName" id="contactFirstName" ng-model="contact.firstName" type="text" class="form-control" name="firstName" placeholder="[[ 'content.list.fields.FIRSTNAME' | translate ]]" ng-required="true">
                <i class="fa fa-user"></i>
            </span>
            <span class="error text-small block" ng-if="contactForm.firstName.$dirty && contactForm.firstName.$error.required" translate="content.form.messages.FIRSTNAMEREQUIRED">FirstName is required.</span>
        </div>

        <div class="form-group" ng-class="{'has-error':contactForm.lastName.$dirty && contactForm.lastName.$invalid, 'has-success':contactForm.lastName.$valid}">
            <label for="contactLastName" class="control-label">
                <span translate="content.list.fields.LASTNAME">Last Name</span>
                <span class="symbol required"></span>
            </label>
            <span class="input-icon">
                <input name="lastName" id="contactLastName" ng-model="contact.lastName" type="text" class="form-control" name="lastName" placeholder="[[ 'content.list.fields.LASTNAME' | translate ]]" ng-required="true">
                <i class="fa fa-user-o"></i>
            </span>
            <span class="error text-small block" ng-if="contactForm.lastName.$dirty && contactForm.lastName.$error.required" translate="content.form.messages.LASTNAMEREQUIRED">LastName is required.</span>
        </div>

        <div class="form-group" ng-class="{'has-error':contactForm.contactEmail.$dirty && contactForm.contactEmail.$invalid, 'has-success':contactForm.contactEmail.$valid}">
            <label for="contactEmail" class="control-label">
                <span translate="content.list.fields.EMAIL">Email</span>
                <span class="symbol required"></span>
            </label>
            <span class="input-icon">
                <input name="contactEmail" id="contactEmail" ng-model="contact.email" type="email" class="form-control" name="email" placeholder="[[ 'content.list.fields.EMAIL' | translate ]]" ng-required="true">
                <i class="fa fa-envelope-o"></i>
            </span>
            <span class="error text-small block" ng-if="contactForm.contactEmail.$dirty && contactForm.contactEmail.$error.required" translate="content.form.messages.EMAILREQUIRED">Email is required.</span>
        </div>


        <div class="form-group" ng-class="{'has-error':contactForm.contactSubject.$dirty && contactForm.contactSubject.$invalid, 'has-success':contactForm.contactSubject.$valid}">
            <label for="contactSubject" class="control-label">
                <span translate="content.list.fields.SUBJECT">Subject</span>
                <span class="symbol required"></span>
            </label>
            <span class="input-icon">
                <input name="contactSubject" id= "contactSubject" ng-model="contact.subject" type="text" class="form-control" name="contactSubject" placeholder="[[ 'content.list.fields.SUBJECT' | translate ]]" ng-required="true">
                <i class="ti-marker-alt"></i>
            </span>
            <span class="error text-small block" ng-if="contactForm.contactSubject.$dirty && contactForm.contactSubject.$error.required" translate="content.form.messages.SUBJECTREQUIRED">Subject is required.</span>
        </div>
        <div class="form-group" ng-class="{'has-error':contactForm.contactMessage.$dirty && contactForm.contactMessage.$invalid, 'has-success':contactForm.contactMessage.$valid}">
            <label for="contactMessage" class="control-label">
                <span translate="content.list.fields.MESSAGE">Message</span>
                <span class="symbol required"></span>
            </label>
            <span class="input-icon">
                <textarea name="contactMessage" id="contactMessage" ng-model="contact.message" rows="10" class="form-control" name="contactMessage" placeholder="[[ 'content.list.fields.MESSAGE' | translate ]]" ng-required="true"></textarea>
                <i class="fa fa-message-o"></i>
            </span>
            <span class="error text-small block" ng-if="contactForm.contactMessage.$dirty && contactForm.contactMessage.$error.required" translate="content.form.messages.CONTACTMESSAGEREQUIRED">Message is required.</span>
        </div>

    <button type="button" ng-click="submitForm(contactForm)" class="btn btn-primary pull-right" ng-disabled="disableSubmit"> <!--  ng-disabled="userForm.$invalid" -->
        <i class="fa fa-spinner fa-spin" ng-if="disableSubmit"></i><i class="fa fa-envelope" ng-if="!disableSubmit"></i> <span translate="content.common.SEND">Send</span>
    </button>
</form>

当我使用检查员时,我找到了这个功能:

<title ng-bind="pageTitle()" class="ng-binding">E-electricity</title>

一个名为pageTitle()的函数,用于自动为每个页面生成标题。我想编辑E-electricity到E-electricity-contact。

0 个答案:

没有答案