Dhana Dhana - 10 months ago 55
AngularJS Question

AngularJS controller not found, for undefined

I am getting AngularJS bad argument error while running the following example, please let me know where I am doing wrong ? Actually the following code is working fine if I run outside/normally, but when I copy/paste this code in my application, it is giving the following error. (this page/tab is displaying from my application's controller like: TestController, which is available in coffeescript. but I don't need any coffeescript for this requirement, I need it in AngularJs. So, In this tab, I need to display the below code/button.

<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">

<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>


var myApp = angular.module('myApplication', []);

myApp.controller('TestController', ['$scope', function($scope){
$scope.test = function(){
<div ng-app="myApplication">
<div ng-controller="TestController">
<div class="tab-pane" id="wizards">

<button type="button" ng-click="test();">Test</button>


Error: [ng:areq] http://errors.angularjs.org/1.4.8/ng/areq?p0=TestController&p1=not%20a%20function%2C%20got%20undefined


This Plunker is working for me

    <link rel="stylesheet" href="style.css">
        <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.min.js">        </script>

    <script src="script.js"></script>

    <div  ng-app="myApplication">
        <div ng-controller="WizardController">
            <button ng-click="test()">Test</button>