Html AngularJs CRUD操作删除不需要的代码

Html AngularJs CRUD操作删除不需要的代码,html,angularjs,Html,Angularjs,我是新来的,在我的项目中使用angularjs。 例如,我正在使用下面的操作 1. Create 2. View 3. Edit 4. List 在这四个操作中,我使用的是4个html页面 我知道列表操作需要一个html页面。 因此,现在我尝试将添加/查看/编辑html页面缩减为单个页面 这里我没有附加我的html和js代码,但我需要了解如何简单地执行这些代码 我正在努力: 1.一页html显示所有记录(列表)。 2.添加/编辑/查看-所有操作都应该是单个html页面 任何人都可以建议最好的方

我是新来的,在我的项目中使用angularjs。 例如,我正在使用下面的操作

1. Create
2. View
3. Edit
4. List
在这四个操作中,我使用的是4个html页面

我知道列表操作需要一个html页面。 因此,现在我尝试将添加/查看/编辑html页面缩减为单个页面

这里我没有附加我的html和js代码,但我需要了解如何简单地执行这些代码

我正在努力: 1.一页html显示所有记录(列表)。 2.添加/编辑/查看-所有操作都应该是单个html页面


任何人都可以建议最好的方法或演示。

您可以使用相同的html进行创建和编辑

要在视图中使用相同的html,请尝试将mode作为额外参数

模式:创建、编辑和查看


您可以在“查看”模式下禁用整个html。

您可以使用相同的html进行创建和编辑

要在视图中使用相同的html,请尝试将mode作为额外参数

模式:创建、编辑和查看


您可以在“查看”模式下禁用整个html。

我将它们保留在相同的模板中,用于创建和编辑,以避免在需求发生变化时在两个位置更新表单

模块可以具有定义的路由:

.state('home.contentFeeds', {
          abstract: true,
          url: '/content-feeds',
          template: '<div ui-view></div>',
          controller: function () {
          }
        })
        .state('home.contentFeeds.list', {
          url: '/list?status&published',
          templateUrl: 'app/administrator/content-feeds/list/list-content-feeds.html',
          controller: 'ListContentFeedsController'
        })
        .state('home.contentFeeds.upsert', {
          url: '/upsert/:contentFeedId',
          templateUrl: 'app/administrator/content-feeds/upsert/upsert-content-feed.html',
          controller: 'UpsertContentFeedController'
        })
        .state('home.contentFeeds.view', {
          url: '/view/:contentFeedId',
          templateUrl: 'app/administrator/content-feeds/view/view-content-feed.html',
          controller: 'ViewContentFeedController'
        })
.state('home.contentFeeds'{
摘要:没错,
url:“/content feed”,
模板:“”,
控制器:函数(){
}
})
.state('home.contentFeeds.list'{
url:“/list?状态&已发布”,
templateUrl:'app/administrator/content feeds/list/list content feeds.html',
控制器:“ListContentFeedsController”
})
.state('home.contentFeeds.upsert'{
url:“/upsert/:contentFeedId”,
templateUrl:'app/administrator/content feed/upsert/upsert content feed.html',
控制器:“UpsertContentFeedController”
})
.state('home.contentFeeds.view'{
url:“/view/:contentFeedId”,
templateUrl:'app/administrator/content feed/view/view content feed.html',
控制器:“ViewContentFeedController”
})
我更喜欢将路由、html视图和控制器命名为包含单词upsert(源自up日期和sert单词)

编辑表单的字段可能比创建表单的字段少,在这种情况下,您可以使用
ng show
隐藏字段。您还需要使用
ng required
选择退出字段,以便它们不会被验证

如果是新表单/编辑表单,则可以检查是否存在传递给路由的id


视图表单应该分开保存,因为这样可以显示信息,而不需要对html输入控件进行大量标记。

我将它们保留在相同的模板中以供创建和编辑,以避免在需求发生变化时在两个位置更新表单

模块可以具有定义的路由:

.state('home.contentFeeds', {
          abstract: true,
          url: '/content-feeds',
          template: '<div ui-view></div>',
          controller: function () {
          }
        })
        .state('home.contentFeeds.list', {
          url: '/list?status&published',
          templateUrl: 'app/administrator/content-feeds/list/list-content-feeds.html',
          controller: 'ListContentFeedsController'
        })
        .state('home.contentFeeds.upsert', {
          url: '/upsert/:contentFeedId',
          templateUrl: 'app/administrator/content-feeds/upsert/upsert-content-feed.html',
          controller: 'UpsertContentFeedController'
        })
        .state('home.contentFeeds.view', {
          url: '/view/:contentFeedId',
          templateUrl: 'app/administrator/content-feeds/view/view-content-feed.html',
          controller: 'ViewContentFeedController'
        })
.state('home.contentFeeds'{
摘要:没错,
url:“/content feed”,
模板:“”,
控制器:函数(){
}
})
.state('home.contentFeeds.list'{
url:“/list?状态&已发布”,
templateUrl:'app/administrator/content feeds/list/list content feeds.html',
控制器:“ListContentFeedsController”
})
.state('home.contentFeeds.upsert'{
url:“/upsert/:contentFeedId”,
templateUrl:'app/administrator/content feed/upsert/upsert content feed.html',
控制器:“UpsertContentFeedController”
})
.state('home.contentFeeds.view'{
url:“/view/:contentFeedId”,
templateUrl:'app/administrator/content feed/view/view content feed.html',
控制器:“ViewContentFeedController”
})
我更喜欢将路由、html视图和控制器命名为包含单词upsert(源自up日期和sert单词)

编辑表单的字段可能比创建表单的字段少,在这种情况下,您可以使用
ng show
隐藏字段。您还需要使用
ng required
选择退出字段,以便它们不会被验证

如果是新表单/编辑表单,则可以检查是否存在传递给路由的id


视图表单应该分开保存,因为这样可以显示信息,而不需要对html输入控件进行大量标记。

查看和编辑是完全不同的。您不应该对这两个模板使用相同的模板。编辑和创建有时可以使用相同的模板。试一试,当你遇到具体问题时,可以问一个具体的问题。查看和编辑是完全不同的。您不应该对这两个模板使用相同的模板。编辑和创建有时可以使用相同的模板。试一试,当你有具体的问题时,问一个具体的问题。