【发布时间】:2017-09-18 04:35:15
【问题描述】:
我在 Angular Js 中有一个警报功能,到目前为止它只出现在屏幕上,但您可以使用 close 功能关闭它。
到目前为止,这些参数是在 HTML 标记中调用的,我想知道如何将样式应用于它们。例如。在警报主题和警报消息之间进行中断。
代码如下:
索引
<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>
【问题讨论】:
-
您的代码让您看起来好像什么都没试过,而不是什么都试过......
标签: javascript css angularjs