Search code examples
angularjsangular-ui-routercursor

Unable to get a clickable link in angularjs ui-router


I am new to angular (router ui-sref in angularjs) and I am following a tutorial. But after code execution I am not able to get the clickable link. Instead of a clickable cursor, an edit cursor(|) is shown. Following is my code:

<!DOCTYPE html>
<html>
   <head>
      <meta charset="ISO-8859-1">
      <title>Insert title here</title>
      <!-- Latest compiled and minified CSS -->
      <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
      <!-- Optional theme -->
      <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
      <!-- Latest compiled and minified JavaScript -->
      <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
      <script src = "https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
      <!-- SideBar Style Sheet -->
      <link rel="stylesheet" type="text/css" href="../css/SideBar.css">
      <script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-router/0.4.2/angular-ui-router.js"></script>
      <!-- SideBar Transition JS -->
      <script type="text/javascript" src="../javascript/sidebarAni.js"></script>
      <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">

<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min

" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>


      
   </head>
   <body ng-app="myApp" >
  
  <a ui-sref="applyLeave">Apply Leave</a>
  <a href="#">Leave Balance1</a>
  <a href="#">Other Option</a>
  <a href="#">Other Option</a>
</div>
      <div  id="main">
         <ui-view></ui-view>
      </div>
  <script >
var v=angular.module("myApp",["ui.router"]);
v.config(function($stateProvider){
	$stateProvider
	.state("applyLeave",{
		url:"/applyLeave",
		templateUrl:"try.html",
		controller:"leaveController",
		controllerAs:"leaveController"
	})
	.controller("leaveController",function($scope)
			{
		
			})
});
</script>
   </body>
</html>

Please Help


Solution

  • It should be like this. you have a mistake in closing }); so this the controller puted on config body.

     var v=angular.module("myApp",["ui.router"]);
     v.config(function($stateProvider){
     $stateProvider
     .state("applyLeave",{
        url:"/applyLeave",
        templateUrl:"",
        controller:"leaveController",
        controllerAs:"leaveController"
     })
    }); 
    
    v.controller("leaveController",function($scope){
    
    });
    

    Demo