javascript - How can i load pages dynamically with angularJS? -
javascript - How can i load pages dynamically with angularJS? -
i'm finish newbie angularjs. i'm searching clear illustration phone call pages ajax.
first question is:
how can create ajax request?
second question is:
i don't want utilize ng-click links. can't add together ng-click attr elements because dynamic links. how can phone call function clicking links between #menu
?
for example:
class="snippet-code-js lang-js prettyprint-override">// controller var ceoapp = angular.module('ceoapp', []).config(function($interpolateprovider){ $interpolateprovider.startsymbol('{[{').endsymbol('}]}'); }); ceoapp.controller('ajaxloadctrl', function(){});
class="snippet-code-html lang-html prettyprint-override"><!-- 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 don't know what's next now...
any help great!
to understanding must be:
$('#menu a').click(function(){ $.ajax({ type: 'post', datatype: 'html', url: $(this).attr('href'), success: function(data){ $('#view').html(data); } }); });
above illustration loads clicked link's url, , gets response html , show in view.
i'm asking this. sorry lame question need this...
this need , route page or load dynamically https://github.com/angular-ui/ui-router
javascript html angularjs
Comments
Post a Comment