$ when using angular-bootstrap ($ modalInstanceProvider <- $ modalInstance)

I played with this mistake, but I can not understand it. The problem started when I clicked the angular-bootstrap mod added to the prod server. The initial error was "AngularJS error: unknown provider: aProvider <- a" im, I'm sure I get this error because my files were skipped correctly. So I went through the controllers and found that I did not inject the $ modal instance into my controllers, and that was when I ran into this problem. When I inject $ modalInstance into my controller in a reduced format, I get this error. I do not use the angular-bootstrap format because I have a lot going on and many controllers on the im building site, so I combined everything into one controller instead of several functions.

My controller:

.controller('CreateGroupCtrl', ['$scope', '$http', '$window', '$cookies', '$modal', '$log', 'FeedService', '$modalInstance', 
function CreateGroupCtrl($scope, $http, $window, $cookies, $modal, $log, $modalInstance, FeedService) {
$scope.createGroupCall = function createGroupCall(teacher, name) {
    if(teacher != null && name != null) {
            FeedService.createGroupCall($cookies.token, $window.sessionStorage.user, teacher, name).success(function(data) {
            console.log('GroupCreated');
        }).error (function(status,data,token) {
            console.log(status);
            console.log(data);
        });
    } else {
        alert("Error!");
    }

}

/***********ANGULAR-UI MODAL CODE**********/
$scope.open = function (size) {
    var modalInstance = $modal.open({
        templateUrl: 'CreateGroupContent.html',
        controller: CreateGroupCtrl,
        size: size
});

modalInstance.result.then(function (selectedItem) {
    $scope.selected = selectedItem;
}, function () {
    $log.info('Modal dismissed at: ' + new Date());
    });
};

$scope.ok = function () {
    $modalInstance.close();
};

$scope.cancel = function () {
    $modalInstance.dismiss('cancel');
};

}]);

My template:

<button ng-controller="CreateGroupCtrl" ng-click="open()" type="button" id="creategroup" class="btn ns-btn">
        <img class="ns-add" src="images/createGroup.png">
        <p class="create">Create Group</p>
</button>

<div>
    <script type="text/ng-template" id="CreateGroupContent.html">
        <div class="modal-header">
                <h2 class="modal-title ns-modal-title">Create A Group</h2>
                <button class="ns-modal-close" ng-click="cancel()"><img src="images/xCancel.png"></button>
            </div>
            <div class="modal-body">
                <form class="form-signin" role="form">
                    <input type="text" class="form-control ns-modal-form" placeholder="Teacher" ng-model="create.teacher" required autofocus>
                    <input type="text" class="form-control ns-modal-form" placeholder="Group Name" ng-model="create.name" required>

                </form>
            </div>
            <div class="modal-footer">
                <button class="btn ns-modal-add ns-btn" ng-click="createGroupCall(create.teacher, create.name); ok();" type="submit">Create</button>
            </div>
        </div>
    </script>
</div>
+4
2

.

, $modal , . $modalInstance , $modal. , $modalInstance

: http://plnkr.co/edit/khzNQ0?p=preview

, ( ) scope, $scope . $rootScope, :

$scope.open = function (size) {
    var modalInstance = $modal.open({
        templateUrl: 'CreateGroupContent.html',
        controller: CreateGroupCtrl,
        size: size,
        scope: $scope
});

, ok() cancel() .

+4

, FeedService $modalInstance . .

0

All Articles