html - AngularJS function unable to be called in ng-view -
using following code, able use angularjs carousel.
<!doctype html> <html ng-app="app"> <head> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.js"></script> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular-animate.js"></script> <script src="http://angular-ui.github.io/bootstrap/ui-bootstrap-tpls-1.2.1.js"></script> <link href="http://netdna.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"> <script type="text/javascript"> var app = angular.module('app', ['ui.bootstrap']); app.controller('carouseldemoctrl', carouseldemoctrl); function carouseldemoctrl($scope){ $scope.myinterval = 3000; $scope.nowrapslides = false; $scope.activeslide = 0; $scope.slides = [ { image: 'http://lorempixel.com/400/200/' }, { image: 'http://lorempixel.com/400/200/food' }, { image: 'http://lorempixel.com/400/200/sports' }, { image: 'http://lorempixel.com/400/200/people' } ]; } </script> </head> <body> <div> write name here <input type="text" ng-model="name"> hi {{name}} photos: <div ng-controller="carouseldemoctrl" id="slides_control"> <div> <uib-carousel interval="myinterval" active="activeslide"> <uib-slide ng-repeat="slide in slides" index="$index"> <img ng-src="{{slide.image}}" style="margin:auto;"> <div class="carousel-caption"> <h4>slide {{$index+1}}</h4> </div> </uib-slide> </uib-carousel> </div> </div> </div> </body> </html>
however, when divide content subsequent app.js , serve html snippet including carousel using ng-view follows, doesn't work.
<body ng-app="app"> <div ng-include='"./templates/header.html"'></div> <div ng-view></div> <div ng-include='"./templates/footer.html"'></div> <script src="scripts/angular.js"></script> <script src="scripts/angular-route.min.js"></script> <script src="scripts/angular-ui/ui-bootstrap-tpls.min.js"></script> <script src="scripts/app.js"></script> </body>
it seems it's not able refer function? following console error
angular.js:13708 error: [ng:areq] argument 'carouseldemoctrl' not function, got undefined
any appreciated! got code carouseldemo https://codepen.io/fabiano/pen/laczk
Comments
Post a Comment