Last active
August 29, 2015 14:01
-
-
Save shmdhussain/c802c7a59c78d8e498da to your computer and use it in GitHub Desktop.
Angular Directive Demo Issue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create a new module | |
var myApp = angular.module('myApp', ['ngRoute']); | |
// register a new service | |
//myApp.value('appName', 'MyCoolApp'); | |
// configure existing services inside initialization blocks. | |
myApp.config(function($locationProvider,$routeProvider) { | |
$routeProvider | |
.when('/p1', { | |
templateUrl:'partials/page1.html' | |
}) | |
.when('/p2', { | |
templateUrl:'partials/page2.html' | |
}) | |
.when('/default', { | |
templateUrl:'partials/default.html' | |
.otherwise({ | |
redirectTo:'/default' | |
}); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
myApp.controller('parentCtrl',['$scope','$window','$location',function ($scope,$window,$location) { | |
}]); | |
myApp.directive('mytoggle',function(){ | |
console.log("inside dir"); | |
//ALERTS | |
jQuery(".toggle").click(function (e) { | |
console.log("ddd"); | |
console.log("class names: "+jQuery(e.target).attr('class')); | |
jQuery(".show").slideToggle("slow"); | |
}); | |
return true; | |
}); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<p><a href="#/p1">page 1</a></p> | |
<p><a href="#/p2">page 2</a></p> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html xmlns:ng="http://angularjs.org" lang="en" id="ng-app" ng-app="myApp"> | |
<head> | |
<meta charset="utf-8"> | |
<title>Angular App</title> | |
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.15/angular.min.js"></script> | |
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.15/angular-route.js"></script> | |
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> | |
<script src="app.js"></script> | |
<script src="js/controllers/ctrl.js"></script> | |
<style type="text/css"> | |
.show{display:none} | |
</style> | |
</head> | |
<body> | |
<div ng-controller="parentCtrl" class=""> | |
<div ng-view> | |
</div> | |
</div> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div> | |
<p mytoggle class="toggle">Toggle ME Page 1</p> | |
</div> | |
<div class="show"> | |
<p>In Page One</p> | |
<p>In Page One</p> | |
<p>In Page One</p> | |
<p>In Page One</p> | |
<p>In Page One</p> | |
<p>In Page One</p> | |
<p>In Page One</p> | |
<p>In Page One</p> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div> | |
<p mytoggle class="toggle">Toggle ME Page2</p> | |
</div> | |
<div class="show"> | |
<p>In Page Two</p> | |
<p>In Page Two</p> | |
<p>In Page Two</p> | |
<p>In Page Two</p> | |
<p>In Page Two</p> | |
<p>In Page Two</p> | |
<p>In Page Two</p> | |
<p>In Page Two</p> | |
<p>In Page Two</p> | |
<p>In Page Two</p> | |
<p>In Page Two</p> | |
<p>In Page Two</p> | |
<p>In Page Two</p> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment