我使用角度js并遇到http://apparently.me.uk/angularjs-view-specific-sidebars/
的问题当我替换块时,在替换块中忽略ng-click simple example here(单击带有提醒词的文本)
脚本代码:
var test = angular.module('test', ['sheikcontrolls']);
var sheikContolls = angular.module("sheikcontrolls",[]);
sheikContolls.controller('BaseController', function ($scope) {
$scope.name="Alex";
$scope.getName = function(){
return $scope.name;
};
$scope.alertName = function(){
alert($scope.name);
};
});
//SideBar here
var blocks = {};
test.directive('customOnChange', function() {
return {
restrict: 'A',
link: function (scope, element, attrs) {
var onChangeFunc = scope.$eval(attrs.customOnChange);
element.bind('change', onChangeFunc);
}
};
});
test.directive(
'blockInsertion',
function () {
return {
restrict: 'A',
link: function (scope, iElement, iAttrs) {
var key = iAttrs.blockInsertion;
blocks[key] = iElement;
// Assume that block-insertion directives won't get
// removed after they're inserted. A more robust
// implementation would clean these up on $destroy.
}
};
}
);
test.directive(
'blockReplacement',
function () {
return {
restrict: 'A',
link: function (scope, iElement, iAttrs) {
var key = iAttrs.blockReplacement;
// Prepare to move our element to its corresponding
// block insertion point.
iElement.remove();
if (! blocks[key]) {
// No matching block insertion, so just hide.
return;
}
blocks[key].replaceWith(iElement);
scope.$on(
'$destroy',
function () {
// Restore the insertion element.
iElement.replaceWith(blocks[key]);
}
);
}
}
}
);