角度属性指令可以替换父元素和子元素吗?

时间:2019-10-07 12:42:18

标签: angular angular-directive

角度属性指令可以替换父元素和子元素吗?

这就是我的意思。我可以创建一个指令来替换下面的“父样式”和“子样式”

<div class="parent-stylings">
    <div class="child-stylings"></div>
</div>

变成这样

<div #myCustomDirective></div>

1 个答案:

答案 0 :(得分:2)

是的,您只需要更改组件的选择器。就这么简单。

Documents
  |_ companies
    |_ foo
      |_ brokers
      |_ press articles
      |_ img


static let documentsDirectory: URL? = {
     let url = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first
     return url
}()


func eraseContent(at path: String) throws {
    do {
        guard let documentDirectory = FileSystem.documentsDirectory else {
            throw FilesError.documentDirectoryUnavailable
        }
        let url = documentDirectory.appendingPathComponent(path).path
        let path = url.replacingOccurrences(of: "file://", with: "")

        try manager.removeItem(atPath: path)
    } catch {
        Logger.error(path+" || "+error.localizedDescription)
        return
    }
}

See it working live !