Сообщение от Risa
|
Помогите, пожалуйста!
$scope.varName = ' > <span class = "btnLink" ng-click = "infoSomeProc()">Информация</span>';
|
Вот вариант собственно с переменной...
<!DOCTYPE html>
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=windows-1251' />
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular.min.js"></script>
<style type='text/css'>
.btnLink {
color: red;
cursor: pointer;
}
</style>
<script type='text/javascript'>
angular.module('MyMod', [])
.directive('myBuildElements', ['$compile',
function($compile) {
return {
restrict: 'E',
link: function(scope, element) {
element.append(scope.varName);
$compile(element.contents())(scope);
}
};
}
])
.controller('MyCtrl', function($scope) {
$scope.varName='<span class="btnLink" ng-click="infoSomeProc()">Информация</span>';
$scope.infoSomeProc=function(){
alert('Ok');
};
})
</script>
</head>
<body ng-app="MyMod" ng-controller="MyCtrl">
<my-build-elements></my-build-elements>
</body>
</html>