Search code examples
angularjsangular-strap

How to pass scope to AngularStrap $Alert?


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


Solution

  • 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
    });