我在Angular Js中有一个警告函数,目前为止只出现在屏幕上,但您可以使用关闭功能关闭它。
这些参数到目前为止称为HTML标签内,我想知道如何将样式应用于它们。例如。在警报主题和警报消息之间进行中断。如何将样式应用于AngularJs中的“警告”功能
这里是代码:
指数
<alert
ng-show="showAlert"
topic="alertTopic"
description="alertMessage"
close="closeAlert()">
</alert>
指令:
parking.directive("alert", function() {
return {
restrict: 'E',
scope: {
topic: '=',
description: '=',
close: '&'
},
templateUrl: "alert.html",
replace: true
};
});
应用:
var parking = angular.module("parking", []);
控制器:
parking.controller("parkingCtrl", function ($scope) {
$scope.appTitle = "[alert]";
$scope.alertTopic = "Something went wrong!";
$scope.alertMessage = "You must inform the plate and the color of the car!"
$scope.showAlert = true;
$scope.closeAlert = function() { $scope.showAlert = false; };
});
警报
<div class="alert">
<span class="alert-topic">
<span ng-bind="topic"></span>
</span>
<span class="alert-description">
<span ng-bind="description"></span>
</span>
<a href="" ng-click="close()">Close</a>
</div>
你的代码,使它看起来像你试过没有,而不是一切... – John3136