相关疑难解决方法(0)

在将一些html附加到DOM后初始化AngularJS控制器

有没有办法如何从纯JavaScript使用$ compile?我正在组合基本的javascript和我正在使用Angular的地方,并且找不到如何做这样的事情的方法:http://jsfiddle.net/DavidSlavik/bFdcJ/1/

我想我需要使用$ compile但是从没有任何范围的地方.

angular.module('myApp', []);

function ExpensesCtrl($scope) {

    // Here are some master functions...    

}    


$(function () {

   // Here is the Ajax function that returns html from my MVC action processed with Razor
   // Here I'm not using AngularJS and scopes...
   var htmlFromAjax = '<div id="mapOrder" ng-controller="sortable"><div ng-repeat="item in SortItems">{{item.Title}}</div></div>';
   $('body').append(htmlFromAjax);

});

function sortable($scope, $http, $element) {

    // Here is the Ajax function that return JSON object. For example it is commented and used static …
Run Code Online (Sandbox Code Playgroud)

angularjs

6
推荐指数
1
解决办法
4706
查看次数

标签 统计

angularjs ×1