在angularjs中带有弹出模式的指令
我有一个指令,根据它出现的某些条件,它会有一个按钮/文本区域/下拉列表。点击该按钮时,应打开一个模式弹出窗口。我怎样才能做到这一点?我没有任何创建小提琴或plnkr的代码 提前谢谢。这是片段在angularjs中带有弹出模式的指令,angularjs,angularjs-directive,bootstrap-modal,Angularjs,Angularjs Directive,Bootstrap Modal,我有一个指令,根据它出现的某些条件,它会有一个按钮/文本区域/下拉列表。点击该按钮时,应打开一个模式弹出窗口。我怎样才能做到这一点?我没有任何创建小提琴或plnkr的代码 提前谢谢。这是片段 //in your main html file <webhook-params></webhook-params> //your directive html code <div class="form-inline"> //show hide condition
//in your main html file
<webhook-params></webhook-params>
//your directive html code
<div class="form-inline">
//show hide conditional scope available here
<div class="form-group">
<input type="text" class="form-control" placeholder="Name" />
</div>
<div class="form-group">
<button class="btn btn-default"
aria-label="Remove" ng-click="someFunc()" >
<i class="glyphicon glyphicon-remove"></i>
</button>
</div>
</div>
//in your app.js file
.directive('webhook-params', ['$scope', function($scope) {
return {
restrict: 'A',
replace: true,
transclude: true,
scope: $scope,
controller: 'ledgerController',
templateUrl: "YOUR_TEMPLATE_URL"
}
}])
//in your controller
$scope.someFunc = function(){
//do something
$scope.myModal = $modal({
scope: $scope,
templateUrl: 'your_file_path',
show: true,
backdrop: "static"
});
}
//在主html文件中
//您的指令html代码
//此处显示隐藏条件作用域
//在app.js文件中
.directive('webhook-params',['$scope',function$scope){
返回{
限制:“A”,
替换:正确,
是的,
范围:$scope,
控制器:“账本控制器”,
templateUrl:“您的模板URL”
}
}])
//在控制器中
$scope.someFunc=函数(){
//做点什么
$scope.myModal=$modal({
范围:$scope,
templateUrl:“您的文件路径”,
秀:没错,
背景:“静态”
});
}
以下是代码片段
//in your main html file
<webhook-params></webhook-params>
//your directive html code
<div class="form-inline">
//show hide conditional scope available here
<div class="form-group">
<input type="text" class="form-control" placeholder="Name" />
</div>
<div class="form-group">
<button class="btn btn-default"
aria-label="Remove" ng-click="someFunc()" >
<i class="glyphicon glyphicon-remove"></i>
</button>
</div>
</div>
//in your app.js file
.directive('webhook-params', ['$scope', function($scope) {
return {
restrict: 'A',
replace: true,
transclude: true,
scope: $scope,
controller: 'ledgerController',
templateUrl: "YOUR_TEMPLATE_URL"
}
}])
//in your controller
$scope.someFunc = function(){
//do something
$scope.myModal = $modal({
scope: $scope,
templateUrl: 'your_file_path',
show: true,
backdrop: "static"
});
}
//在主html文件中
//您的指令html代码
//此处显示隐藏条件作用域
//在app.js文件中
.directive('webhook-params',['$scope',function$scope){
返回{
限制:“A”,
替换:正确,
是的,
范围:$scope,
控制器:“账本控制器”,
templateUrl:“您的模板URL”
}
}])
//在控制器中
$scope.someFunc=函数(){
//做点什么
$scope.myModal=$modal({
范围:$scope,
templateUrl:“您的文件路径”,
秀:没错,
背景:“静态”
});
}
您是否使用任何模式库(角度带、角度引导或任何其他)?@TheMechanical是我使用角度引导您使用任何模式库(角度带、角度引导或任何其他)?@TheMechanical是的,我正在使用angular bootstrapI尝试了上述方法,效果很好,但我无法获取指令的范围,而是获取根范围。如何获取指令的范围?我尝试了上述方法,效果很好,但我无法获取指令的范围,而是获取了根范围。如何获得指令的范围?