1

I am new into both and unable to access angular in my codeigniter code. I have created simple code in angular which is :

<body ng-app="">
  <p>Name : <input type="text" ng-model="name"></p>
  <h1>Hello {{name}}</h1>
</body>

I have also inserted both angular.min.js and angular-route.min.js inside tag but when I run this application, it displays following error in console :

Uncaught Error: [$injector:modulerr]

While if I execute this code seperately, it works perfect. Can anyone please help me out in resolving this issue. PS : I know many have asked this question earlier. I tried given solution but nothing worked out in my case. May be I am unable to understand the solution they have provided. It will be a great help if someone provides a simple solution of given problem.

Thanks in advance.

6
  • show us your angularjs code? Commented Jun 20, 2017 at 14:25
  • <!DOCTYPE html> <html lang="en-US"> <script src="ajax.googleapis.com/ajax/libs/angularjs/1.6.4/…> <body> <div ng-app=""> <p>Name : <input type="text" ng-model="name"></p> <h1>Hello {{name}}</h1> </div> </body> </html> Commented Jun 20, 2017 at 14:26
  • If it helps, I'm fairly certain this isn't a CodeIgniter problem in any way. You can treat the view like any old HTML file, there's no magic. Commented Jun 20, 2017 at 14:30
  • @Goose then why I am facing this error? Commented Jun 20, 2017 at 14:31
  • You are facing this error coz you have failed to add a module in your angular code. Can u show us your angular code (JS part) Commented Jun 20, 2017 at 14:33

1 Answer 1

1

Try this, Will help you

<?php
defined('BASEPATH') OR exit('No direct script access allowed');?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Welcome to CodeIgniter</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
</head>
<body ng-app="">
  <p>Name : <input type="text" ng-model="name"></p>
  <h1>Hello {{name}}</h1>
</body>
</html>
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks a lot Akshay. It worked for me. So the error was because I was not including jquery library?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.