错误:[$编译:multidir]多个指令[表格,表格]要求“形式”上的控制器:其中p形式NG型="">表格、形式、多个、控制器

2023-09-13 04:50:35 作者:南桅

我得到一个形式,我在建设上angularjs此错误。

I am getting this error on a form I am building in angularjs.

`错误:[$编译:multidir]多个指令[表格,表格]要求对形式的控制器:

`Error: [$compile:multidir] Multiple directives [form, form] asking for 'form' controller on:

<div data-ng-controller="shortlistController">
    <ul>
        <li data-ng-repeat="job in jobs">
            <div>{{ job.role }}</div><div>{{ job.salary }}</div><div>{{ job.company }}</div>
        </li>
    </ul>
</div>

<form ng-form>
    <input type="text" ng-model="newRole">
    <input type="text" ng-model="newSalary">
    <input type="text" ng-model="newCompany">
    <input type="text" ng-model="newUrl">
    <button>Submit</button>
</form>

起初我有数据-NG-控制器中的形式,我把它看是否控制器可能会出现的问题。

Initially I had the form within data-ng-controller, I took it out to see if the controller might have been the issue..

如果您认为我需要发布更多code请问,我使用angulars本地路由系统

Please ask if you think I need to post more code, I am using angulars native routing system

推荐答案

您不需要 NG-形式如果你使用 &LT;形式为GT; 因为它会自动被挂在 NG-形式指令。您使用或不能同时使用。

You don't need the ng-form if you're using <form> as it automatically is hooked up to the ng-form directive. You use either or, not both.