Reputation: 3520
I tried almost everything thats available on stackoverflow since none worked posting the same. Really sorry if found duplicate.
I am trying to reset the content of my Bootstrap table on the button click using the function $route.reload()
but when I add it within the click function and even after adding the dependency I get the error Unknown provider: $routeProvider <- $route <- AppController
I am really unsure why am I getting this error.
Here is my code:
<button ng-model="NewDataSet" ng-click="ReloadTable();">Reset</button><br/>
Angularjs:
var app = angular.module('myApp', ['CopyToClipboard','ngRoute'], function() {});
app.controller('AppController2', function($scope,$http,$location,$anchorScroll,$copyToClipboard,$route){
$scope.ReloadTable = function(){
console.log("JRJRJ");
//$window.location.reload();
$route.reload();
}
})
var app = angular.module('myApp', ['CopyToClipboard','ngRoute'], function() {});
app.controller('AppController2', function($scope,$route){
$scope.ReloadTable = function(){
$route.reload();
}
})
I tried lot of things as mentioned in the other answers such as:
I have added the cdn to my HTML file
I tried adding the dependency like this:
app.controller('AppController2',['$route', function($scope,$route){
$scope.ReloadTable = function(){
$route.reload();
}
}]);
I checked out this video. He seems to be doing almost the same but working for him but not for me.
As I ran out of ideas I thought of posting to get some idea/suggestions from you guys.
Based on the comment:
Following are the Angularjs CDN that I am using in my HTML file:
<!-- Angularjs CDN Starts -->
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<script src="https://cdn.rawgit.com/zenorocha/clipboard.js/master/dist/clipboard.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0rc1/angular-route.min.js"></script>
<!-- Angularjs CDN Ends -->
Upvotes: 0
Views: 92
Reputation: 164
Would you please try below.
var app = angular.module('myApp', ['CopyToClipboard','ngRoute'], function() {});
app.controller('AppController2',['$scope','$http','$location','$anchorScroll','$copyToClipboard','$route', function($scope,$http,$location,$anchorScroll,$copyToClipboard,$route){
$scope.ReloadTable = function(){
console.log("JRJRJ");
//$window.location.reload();
$route.reload();
}
}])
var app = angular.module('myApp', ['CopyToClipboard','ngRoute'], function() {});
app.controller('AppController2', ['$scope','$route', function($scope,$route){
$scope.ReloadTable = function(){
$route.reload();
}
}])
Upvotes: 0