在angularjs中的下拉列表中获取空白值

时间:2015-07-06 10:26:01

标签: javascript html angularjs

为什么我在ng-wig中获得空白的controltext值?我创建了一个资源文件,我试图将值加载到下拉列表中

plane.visible=true

1 个答案:

答案 0 :(得分:0)

ControlText超出了scope,因为您使用的是模板,因此您必须在$parent之前添加controlText,如下所示:

<script type="text/ng-template" id="ng-wig/views/ng-wig.html">
<div class="ng-wig">
    <div class="btn-group btn-group-sm wd-wide">
        <button type="button" title="Header" ng-click="execCommand('formatblock', '&lt;h1&gt;')" class="btn btn-sm btn-default"><em class="fa fa-header"></em></button>
        <button type="button" title="Paragraph" ng-click="execCommand('formatblock', '&lt;p&gt;')" class="btn btn-sm btn-default"><em class="fa fa-paragraph"></em></button>
        <button type="button" title="Unordered List" ng-click="execCommand('insertunorderedlist')" class="btn btn-sm btn-default"><em class="fa fa-list-ul"></em></button>
        <button type="button" title="Ordered List" ng-click="execCommand('insertorderedlist')" class="btn btn-sm btn-default"><em class="fa fa-list-ol"></em></button>
        <button type="button" title="Bold" ng-click="execCommand('bold')" class="btn btn-sm btn-default"><em class="fa fa-bold"></em></button>
        <button type="button" title="Italic" ng-click="execCommand('italic')" class="btn btn-sm btn-default"><em class="fa fa-italic"></em></button>
        <button type="button" title="link" ng-click="execCommand('createlink')" class="btn btn-sm btn-default"><em class="fa fa-link"></em></button>
        <button type="button" title="Edit Html" ng-class="{ 'nw-button--active': editMode }" ng-click="toggleEditMode()" class="btn btn-sm btn-default"><em class="fa fa-pencil"></em></button>
        <div class="col-lg-3 pull-right btn-variable btn-var-padding">
            <select class="form-control" ng-model="variable" ng-change="InsertVariable(variable)">
                <option value="">{{$parent.controlText.InsertVariable}}</option>
                <optgroup label="Mailbox">
                    <option value="{%mailbox.email%}">{{$parent.controlText.Email}}</option>
                    <option value="{%mailbox.name%}">{{$parent.controlText.Name}}</option>
                </optgroup>
                <optgroup label="User">
                    <option value="{%user.fullName%}">{{$parent.controlText.FullName}}</option>
                    <option value="{%user.firstName%}">{{$parent.controlText.FirstName}}</option>
                    <option value="{%user.lastName%}">{{$parent.controlText.LastName}}</option>
                    <option value="{%user.email%}">{{$parent.controlText.EmailAddress}}</option>
                    <option value="{%user.phone%}">{{$parent.controlText.PhoneNumber}}</option>
                    <option value="{%user.jobTitle%}">{{$parent.controlText.JobTitle}}</option>
                </optgroup>
            </select>
        </div>
 </div>