如何将范围传递给AngularStrap $ Alert?(How to pass scope to AngularStrap $Alert?)

我只是角度新手,我正在使用angularstrap进行自定义警报,并使用ng-repeat重复对象上的数据

这是我的角度代码

let alertExcpetion = $alert({
    placement: 'top-right',
    type: 'warning',
    show: true,
    keyboard: true
    template: 'alert.template.html'
 });
 

这是alert.template.html

<div class="alert" ng-class="[type ? 'alert-' + type : null]">
        <button type="button" class="close" ng-if="dismissable" ng-click="$hide()">&times;</button>
        <div class="title">
             {{ someScopeTitle }}
        </div>
        <div>
            <table class="table table-alert">
                <tbody>
                    <tr ng-repeat="student in students">
                        <td>{{ student.id }}</td>
                        <td><a href="#" ng-click="myfunction(student.someObject)">View File</a> {{student.fullname}}</td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>
 

加载后,.alert为空,因为它没有读取范围。 有没有办法将范围传递给angularstrap的$ alert?

angular-strap版本v2.1.6 - 2015-01-11

I'm just new in angular and I'm making a customize alert using angularstrap and repeat a data on object using ng-repeat

here is my angular code

let alertExcpetion = $alert({
    placement: 'top-right',
    type: 'warning',
    show: true,
    keyboard: true
    template: 'alert.template.html'
 });
 

and here is the alert.template.html

<div class="alert" ng-class="[type ? 'alert-' + type : null]">
        <button type="button" class="close" ng-if="dismissable" ng-click="$hide()">&times;</button>
        <div class="title">
             {{ someScopeTitle }}
        </div>
        <div>
            <table class="table table-alert">
                <tbody>
                    <tr ng-repeat="student in students">
                        <td>{{ student.id }}</td>
                        <td><a href="#" ng-click="myfunction(student.someObject)">View File</a> {{student.fullname}}</td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>
 

after loading the .alert is empty because it didn't read the scope. is there any possible way to pass scope to angularstrap's $alert?

angular-strap version v2.1.6 - 2015-01-11

最满意答案

为警报调用添加scope

JS

let alertExcpetion = $alert({ placement: 'top-right', type: 'warning', show: true, keyboard: true template: 'alert.template.html', scope:$scope });

Add scope to your alert call .

js

let alertExcpetion = $alert({ placement: 'top-right', type: 'warning', show: true, keyboard: true template: 'alert.template.html', scope:$scope });

更多推荐