I'm a complete newbie with angularjs. I'm searching for an clear example to call pages with ajax.
First question is:
How can i make an ajax request?
Second question is:
I don't want to use ng-click with all links. I can't add ng-click attr to all elements because they are dynamic links. How can i call the function with clicking links between #menu
?
For example:
// Controller
var ceoApp = angular.module('ceoApp', []).config(function($interpolateProvider){
$interpolateProvider.startSymbol('{[{').endSymbol('}]}');
});
ceoApp.controller('AjaxLoadCtrl', function(){});
<!-- View -->
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<html ng-app="ceoApp">
<body ng-controller="AjaxLoadCtrl">
<ul id="menu">
<li><a href="p1">CALL P1</a></li>
<li><a href="p2">CALL P2</a></li>
<li><a href="p3">CALL P3</a></li>
</ul>
</body>
</html>
I really don't know what's next now...
Any help would be great!
To understanding what must be:
$('#menu a').click(function(){
$.ajax({
type: 'post',
dataType: 'html',
url: $(this).attr('href'),
success: function(data){
$('#view').html(data);
}
});
});
Above example loads clicked link's url, and gets response as html and show it in view.
I'm exactly asking for this. Sorry for lame question but i need this...