zoukankan      html  css  js  c++  java
  • AngularJS: 'Template for directive must have exactly one root element' when using 'th' tag in directive template

    .controller('HomeController', function($scope,$location) {
        $scope.userName='天下大势,为我所控!';
        $scope.clkUrl=function(){
            $scope.pageUrl='norout1.html';//更改值
        }
        $scope.clk2=function(){
           alert($scope.userName);
            $scope.userName='司马懿'
        }
    }).directive('bhtml',function(){
        return {
    templateUrl:'norout1.html',
    restrict:'E',
    replace:true

    }
    })
    <div ng-controller="HomeController as homeP"> <p>下面是指令载入文件:<bhtml></bhtml></p> </div>  norout1.html: <p> <pre> 这里是:没有使用路由载入 <button ng-click="clk2()" >看是否能访问到数据</button> <input type="text" ng-model="userName"/> </pre> </p>

    replace:true导致AngularJS: 'Template for directive must have exactly one root element' when using 'th' tag in directive template
    删除或设置为false。
  • 相关阅读:
    Asp.Net Core- 配置组件详解
    ASP.Net Core-依赖注入IoC
    ASP.Net Core-TagHelpers
    Selenium-等待
    Selenium-js
    Selenium-actions
    Selenium-基础操作
    Selenium-简介
    装饰者模式
    设计模式-策略者模式
  • 原文地址:https://www.cnblogs.com/yuzhongwusan/p/4923449.html
Copyright © 2011-2022 走看看